|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15533 Indexing a string variable with a text key returns 1st element of string
Submitted: 2002-02-13 03:08 UTC Modified: 2002-02-13 05:44 UTC
From: fred at observe dot co dot za Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.0.6 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
44 - 25 = ?
Subscribe to this entry?

 [2002-02-13 03:08 UTC] fred at observe dot co dot za
    $arg = '123';
    // prints 123
    echo "arg = $arg<br>\n";
    // prints nothing
    echo "is_array(arg) = ", is_array($arg), "<br>\n";
    // prints 1
    echo "arg[blah] = $arg[blah]<br>\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-13 05:44 UTC]
$string[...] and $string{...} both allow single
character access to strings. the {} variant is 
recommended for PHP 4, but the older version
using [] still works

the indices inside [...] or {...} are interpreted
as integers, strings are casted to integers,
and (int)'blah'  is zero, that's it
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 09:01:27 2024 UTC