RE: String: Arrays of arrays.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux