RE: [PHP] String: Arrays of arrays.

From: Date: Thu, 23 Dec 2004 09:21:48 +0000
Subject: RE: [PHP] String: Arrays of arrays.
Groups: php.general 
Request: Send a blank email to php-general+get-205048@lists.php.net to get a copy of this message
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 23 December 2004 07:39, Song Ken Vern-E11804 wrote: > Hi, > > I have an array of array of strings :- > > $g1 = array("453", "592"); > $g2 = array("e14", "e15", "e13"); > $groups = array($g1, $g2); > > I traverse and print out the value using :- > > for ($i = 0; $i < sizeof($groups); $i++) { > for ($j = 0; $j < sizeof($groups[$i]); $j++) { > print "<!--=$groups[$i][$j]=-->\n"; /* line?? */ > } } print "<!--={$groups[$i][$j]}=-->\n"; (Note curly braces.) Inside strings, PHP does not parse beyond the first-level subscript by default; enclosing the whole reference in {} gives PHP the clue it needs to use both levels of subscripting. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#205048) next »