Doc #55324 [NEW]: No documentation for accessing array elements with curly braces

From: Date: Sat, 30 Jul 2011 12:29:38 +0000
Subject: Doc #55324 [NEW]: No documentation for accessing array elements with curly braces
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-6954@lists.php.net to get a copy of this message
From: Operating system: Windows 7 PHP version: 5.3.6 Package: Documentation problem Bug Type: Documentation Problem Bug description:No documentation for accessing array elements with curly braces Description: ------------ I have only seen documentation for using $var{n} syntax for accessing single characters in strings. Apparently, it is completely interchangeable with $var[n] for arrays as well. Is this intended? Seeing as it is only noted that strings may be accessed using curly braces, I would expect the variable to be typecast to string. Test script: --------------- <?php $foo = array('123'); $bar = 'abc'; echo $foo . "\r\n"; // Outputs "Array", as expected echo $bar . "\r\n"; // Outputs "abc", as expected echo $foo[0] . "\r\n"; // Outputs "123", as expected echo $bar[0] . "\r\n"; // Outputs "123", as expected echo $foo{0} . "\r\n"; // Outputs "123", undocumented (?), expected implicit cast to string, thus expected the output to be "A" echo $bar{0} . "\r\n"; // Outputs "a", as expected ?> Expected result: ---------------- Array abc 123 a A a Actual result: -------------- Array abc 123 a 123 a -- Edit bug report at https://bugs.php.net/bug.php?id=55324&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55324&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55324&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55324&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55324&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55324&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55324&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55324&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55324&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55324&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55324&r=support Expected behavior: https://bugs.php.net/fix.php?id=55324&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55324&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55324&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55324&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55324&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55324&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55324&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55324&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55324&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55324&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55324&r=mysqlcfg

« previous php.doc.bugs (#6954) next »