String: Arrays of arrays.
| From: | Song Ken Vern-E11804 | Date: | Thu, 23 Dec 2004 07:39:16 +0000 |
| Subject: | String: Arrays of arrays. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-205044@lists.php.net to get a copy of this message | ||
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?? */
}
}
But the end result is :-
<!--=Array[0]=-->
<!--=Array[1]=-->
<!--=Array[0]=-->
My expected result is :-
<!--=453=-->
<!--=592=-->
<!--=e14=-->
But when I change the line from:-
print "<!--=$groups[$i][$j]=-->\n"; /* line?? */
to include :-
$cid = $groups[$i][$j];
print "<!--=$cid=-->\n"; /* line?? */
I seem to get the results I want.
Why is this? Is there a syntax error?
Thanx
--
Ken