Simple to fix it. You just need to resolve ambiguity with {}.
> $res = $i * $j;
> $target_array[$i][$j] = $res;
> print("result = $target_array[$i][$j] <br>");
print("result = {$target_array[$i][$j]} <br>");
Regards,
--
Yasuo Ohgaki
<[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>
> 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>");
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
>
> --
> 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]
>
--
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]