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.

Try one of these:
$test_array = array()
or
$test_array = array(0,0,0,0,0,0,0)

Basically, drop the brackets. You use brackets to reference and array element, not the array itself.


On Oct 21, 2004, at 9:28 AM, Shaun wrote:

Hi,

I have been trying for the past two hours to understand why I get an error
with the following code:


<?php
 $test_array[] = array();
 $i = 0;
 while($i < 7){
  $test_array[$i] += $i;
  echo '$day_total[$i] = '.$day_total[$i].'<br>';
 }
?>

Fatal error: Unsupported operand types in
/usr/home/expensesystem/public_html/test.php on line 5

I am trying to create a loop where $i is added to array element $i, and
can't find any information relating to this on google or php.net...

Thanks for your advice.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to