Creating an array of numbers
Posted: Tue Aug 01, 2006 1:14 pm
I have been working on a page that sums up numbers from an array, but the problem I am having is that my array length varies depending on the number of results returned from the database. Essentially is:
At the moment I have to enter in values for $to_sum, ie
Is it possible to have the list of values I need generated into the code? Hopefully this description is thorough enough. Thanks.
Code: Select all
$z = 0;
while(z < $count_from_db)
{
$array_of_num[] = $z;
$z++;
}
$to_sum = array($array_of_num);Code: Select all
$to_sum = array('0','1','2');