Odp: [PHP-WINDOWS] RE: Two dimentional array
| From: | Piotr Plusa | Date: | Fri, 23 Jun 2000 14:38:42 +0000 |
| Subject: | Odp: [PHP-WINDOWS] RE: Two dimentional array | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-612@lists.php.net to get a copy of this message | ||
----- Wiadomooæ oryginalna -----
Od: Nold, Mark <Mark.Nold@normandy.com.au>
Do: 'Nasir Ali' <nal@mta.ca>; <php-windows@lists.php.net>
Wys³ano: 23 czerwca 2000 03:02
Temat: [PHP-WINDOWS] RE: Two dimentional array
> --------------------------------------------------------------------------
--
> -----------------
> Disclaimer: The information contained in this email is intended only for
the
> use of the person(s) to whom it is addressed and may be confidential or
> contain legally privileged information. If you are not the intended
> recipient you are hereby notified that any perusal, use, distribution,
> copying or disclosure is strictly prohibited. If you have received this
> email in error please immediately advise us by return email at
> postmaster@normandy.com.au and delete the email document without making a
> copy.
> --------------------------------------------------------------------------
--
> -----------------
>
>
> You are missing a few curly braces by the looks of it...
>
> I find it better to traverse arrays with a while
>
> reset($myarray);
> while(list($key,$value) = each($myarray)){
> echo "$key $value<br>\n";
> }
>
>
> for a 2D array try:
>
> reset($myarray);
> while(list($key,$row) = each($myarray)){
> echo "$key ";
> while(list($col,$value) = each($row)){
> echo "[$col:$value] ";
> }
> echo "<br>\n";
> }
>
> mn
>
>
>
>
>
> Thanks Zak,
>
> It's really helpfull. Now I feel like dumb axx hole because I following
> code is not working... What am I doing wrong????
>
>
> <?php
>
> $myarray[0][0] = 'A';
> $myarray[0][1] = 'B';
> $myarray[0][2] = 'I';
> $myarray[1][0] = 'C';
> $myarray[1][1] = 'D';
> $myarray[1][2] = 'J';
> $myarray[2][0] = 'E';
> $myarray[3][0] = 'F';
> $myarray[3][1] = 'Z';
> $myarray[3][2] = 'G';
> $myarray[3][3] = 'Q';
> $myarray[4][0] = 'H';
>
> for($x=0; $x < count($myarray); $x++)
> for($y=0; $y < count($myarray[$x]); ++$y)
> echo $myarray[$x][$y]."<br>"; file://it gives me parse error on
> this line
>
> ?>
>
Hi!
Try print instead of echo.
Piotr Plusa