Doc #55324 [Opn->Csd]: No documentation for accessing array elements with curly braces

From: Date: Wed, 14 Nov 2012 17:08:28 +0000
Subject: Doc #55324 [Opn->Csd]: No documentation for accessing array elements with curly braces
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-9127@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55324&edit=1 ID: 55324 Updated by: googleguy@php.net Reported by: kieran at menor dot dk Summary: No documentation for accessing array elements with curly braces -Status: Open +Status: Closed Type: Documentation Problem Package: Documentation problem Operating System: Windows 7 PHP Version: 5.3.6 -Assigned To: +Assigned To: googleguy Block user comment: N Private report: N New Comment: This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. Previous Comments: ------------------------------------------------------------------------ [2012-11-14 17:07:55] googleguy@php.net Automatic comment from SVN on behalf of googleguy Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=328358 Log: Added note for accessing array elements with curly braces - fixes bug #55324 ------------------------------------------------------------------------ [2011-07-30 12:32:50] kieran at menor dot dk And obviously, I meant to correct line 10, not line 9. >_> ------------------------------------------------------------------------ [2011-07-30 12:31:36] kieran at menor dot dk Made a tiny mistake. Obviously, the expected result for line 9 in the script is "a" and not "123". ------------------------------------------------------------------------ [2011-07-30 12:29:38] kieran at menor dot dk 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 this bug report at https://bugs.php.net/bug.php?id=55324&edit=1

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