On Thu, 21 Oct 2004 14:28:26 +0100, Shaun <shaunthornburgh@xxxxxxxxxxx> 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(); //Change it to $test_array=array(); /*Your statement adds an array to the current+1 position of the array since you've put the [] after the variable the PHP interpreter initializes it as an array type of variable so it takes that action*/ > $i = 0; > while($i < 7){ > $test_array[$i] += $i; > echo '$day_total[$i] = '.$day_total[$i].'<br>'; // Change the single quotes to double quotes // i.e. echo "{$day_total[$i]}={$day_total[$i]}<br />"; // Add ++$i; here > } > ?> Notes: -Always use double quotes if you want to concatanate vars with strings. -Whe ur using arrays in ur strings that is to be concatenated delimit the array by { and }. -Take a look at sprintf function to better format strings in case ur familiar with C coding style. -Sometimes googling might not help nor PHP.net. So, the PHP manual is ur friend. e.g you could go to Array section in PHP manual and find out what's up :) > > 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 > > Hope that helps. -- M.Saleh.E.G 97150-4779817 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php