You are here: Re: dynamically adding to multidimensional array « PHP Programming Language « IT news, forums, messages
Re: dynamically adding to multidimensional array

Posted by pauld on 12/20/05 14:01

Thanks. adding the error reporting gives me a load of stuff about array
indiceds not defined. i thought PHP dynamically sorted out array
lengths. is there a 'better' way to do it than just let the scriptsort
it out ?

I want my results to end up as

results[0] => date,ID,value
results[1] => date,ID,value
results[2] => date,ID,value
etc etc

( there is probably a better way of resetting the temparray but ive
not found it !)

$i=0;
while ($a2=mysql_fetch_assoc($a1))
{$temparray=array();
array_push($temparray,$a2['ID'].$a2['date'],$a2['value']);
$results[$i] = array($temparray);
if (isset($temparray)) {reset($temparray);}
print '<br>'.$i.':';
print_r($results[$i]).'<br>';
$i=$i++;
}
gives

0:Array ( [0] => Array ( [0] => 2005-10-07 [1] => 350 [2] => 21 ) )

0:Array ( [0] => Array ( [0] => 2005-10-28 [1] => 473 [2] => NC2 ) )

0:Array ( [0] => Array ( [0] => 2005-10-03 [1] => 337 [2] => NC4 ) )

dont know why the $i counter is incrementing the array

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация