Re: Array Question

From: Date: Thu, 18 Apr 2002 22:08:21 +0000
Subject: Re: Array Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-93611@lists.php.net to get a copy of this message
On Thursday, April 18, 2002, at 04:38 PM, Jason Lam wrote:
$arr2 is a 2d array. $arr1[0] = 1; $arr1[1] = 10; $arr2[0] = $arr1; print $arr2[0][1]; Result will be 10 But, $arr1[0] = 1; $arr1[1] = 10; $arr2[0] = $arr1; $arr3 = each($arr2); print $arr3[1];
What are you expecting? Check out the documentation for each() at http://www.php.net/manual/en/function.each.php At this point $arr3 should look like this (I think, but try print_r($arr3) to be sure): { 0 => 0, 1 => array ( 0 => array ( 0 => 1, 1 => 10 ) ), key => 0, value => array ( 0 => array ( 0 => 1, 1 => 10 ) ) }
Result is not 10. So, function "each" is not taking the whole $arr2[0] out...... My question is what function should I use to iterate array elements (with arrays in it)?
How about foreach()? -Steve
Jay -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#93611) next »