On Thu, 21 Oct 2004 14:28:26 +0100, Shaun <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have been trying for the past two hours to understand why I get an error
> with the following code:
>
> $test_array[] = array();
//Change it to $test_array=array();
/*Your statement adds an array to the curr
On Thu, 2004-10-21 at 15:04 +0100, Graham Cossey wrote:
> Oh @#*!
> Thanks Greg, I always get that one wrong !
>
> $test_array = array();
>
> :)
a few less lines version:
$test_array = array();
for ($i=0; $i<7; $i++)
$test_array[$i] = $i;
print_r($test_array);
hth,
-Robby
--
/
Oh @#*!
Thanks Greg, I always get that one wrong !
$test_array = array();
:)
> -Original Message-
> From: Graham Cossey [mailto:[EMAIL PROTECTED]
> Sent: 21 October 2004 14:48
> To: Shaun; [EMAIL PROTECTED]
> Subject: RE: [PHP] Strange Array Error
>
>
> [snip]
&g
That is, expected results, *apart* from the infinite loop you'll have
due to not incrementing $i
Cheers
Chris
Chris Dowell wrote:
Shaun
The problem is that you've assigned $test_array[] = array();
This means that the first element ($test_array[0]) is an array.
You're then trying to add $i to it,
You are making the first element of the array $test_array and array
item. An array inside and array.
$test_array[] = array() is the same as $test_array[0] = array()
So what you are trying to do is add $i to an array. Kind of like trying
to figure out what happens when you add 1 to the color red.
[snip]
>
> Hi,
>
> I have been trying for the past two hours to understand why I get
> an error
> with the following code:
>
> $test_array[] = array();
> $i = 0;
> while($i < 7){
> $test_array[$i] += $i;
> echo '$day_total[$i] = '.$day_total[$i].'';
> }
> ?>
>
> Fatal error: Unsuppor
Shaun
The problem is that you've assigned $test_array[] = array();
This means that the first element ($test_array[0]) is an array.
You're then trying to add $i to it, as in $test_array[$i] =
$test_array[$i] + 1;
in terms of types what you're doing is array = array + integer
Which doesn't make any
On Thu, 21 Oct 2004 14:28:26 +0100, Shaun <[EMAIL PROTECTED]> wrote:
> I have been trying for the past two hours to understand why I get an error
> with the following code:
>
> $test_array[] = array();
$test_array = array();
> $i = 0;
> while($i < 7){
> $test_array[$i] += $i;
$test_array[
8 matches
Mail list logo