note 51093 deleted from function.echo by tularis

From: Date: Sat, 19 Mar 2005 14:08:57 +0000
Subject: note 51093 deleted from function.echo by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-86688@lists.php.net to get a copy of this message
Note Submitter: messer(at)abv.bg Reason: useless ---- Just found out some strange (at least to me) bahavior of echo when it is used with nested arrays. PHP5 with Apache2 for Win32 I use (wow, it's as if Yoda said that :) ) Here's the example: <?php // the array in question: $blah[0] = array(7, 5, 3, 1); // echo 'string'.$blah[0][2]; works fine: echo 'This is blah[0] - '.$blah[0]."<br />\n"; echo 'this is blah[0][2] - '.$blah[0][2]; ?> Output is: This is blah[0] - Array; this is blah[0][2] - 3 So far so good. However, when you echo it like this you get to the interesting part: <?php // echo "string $blah[0][2]"; doesn't recognize the nested array. echo "This is blah[0] - $blah[0]; "; echo "this is blah[0][2] - $blah[0][2]"; ?> Output: This is blah[0] - Array; this is blah[0][2] - Array[2] Here the 'Array[2]' part is what bothers me. I had a script I coudn't get working right for a while, and this seems to have been the problem. The '[2]' at the end is obviously interpreted as part of the string that includes the variable name. Hope that's of some help to somebody. Cheers, Emil Nachev

« previous php.notes (#86688) next »