You just do something like this:
<?
$arr = array(0,23,4,2,1);
for($i = 0 ; $i < 10 ; ++$i)
$arrB[] = $arr;
while(list(,$my_array) = each($arrB))
while(list($key,$val) = each($my_array))
echo $key.' -> '.$val."\n";
?>
Just throw arrays into arrays :O)
--Joe
On Fri, Apr 06, 2001 at 11:18:19AM -0600, [EMAIL PROTECTED] wrote:
>
>
> Joe Stump wrote:
> >
> > A copy and paste into foo.php and then a php -q foo.php yielded results for
> > me.
>
> Yeah, it's giving me results too today. I don't know what went wrong
> yesterday.
>
> To extend my question, I'm trying to work with multidimensional arrays.
>
> For example, I would like to do this:
>
> <?
> error_reporting(E_ALL);
>
> $target_array = array();
>
> echo "starting <br>";
>
> for( $i=0; $i<5; $i++ )
> for( $j=0; $j<5; $j++ )
> {
> $res = $i * $j;
> $target_array[$i][$j] = $res;
> print("result = $target_array[$i][$j] <br>");
> }
> echo "done";
> ?>
>
> And this is my result today:
> starting
> result = Array[0]
> result = Array[1]
> result = Array[2]
> result = Array[3]
> result = Array[4]
> result = Array[0]
> result = Array[1]
> result = Array[2]
> result = Array[3]
> result = Array[4]
> result = Array[0]
> result = Array[1]
> result = Array[2]
> result = Array[3]
> result = Array[4]
> result = Array[0]
> result = Array[1]
> result = Array[2]
> result = Array[3]
> result = Array[4]
> result = Array[0]
> result = Array[1]
> result = Array[2]
> result = Array[3]
> result = Array[4]
> done
>
> My thinking is that PHP ought to be like C when doing simple stuff like
> this.
> I must have something wrong with the declaration of the array.
>
> How do you declare a multidimensional array??!!??
> How do you work with it then???
>
> Thanks in advance!!
>
> John
/******************************************************************************\
* Joe Stump - PHP/SQL/HTML Developer *
* http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net *
* "Better to double your money on mediocrity than lose it all on a dream." *
\******************************************************************************/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]