[thelist] [PHP] oddity: popping array from function

Howard Cheng howcheng at ix.netcom.com
Wed Feb 26 11:33:01 CST 2003


At 10:03 AM 2/26/2003 -0600, Erik Mattheis wrote:
>$results = array();
>
>while ($results []= mysql_fetch_assoc($result));

If I read this correctly, wouldn't each array member of the $results array
be an array itself?


>$structure = array();
>
>// this is the function, shortened to illustrate
>function returnItem($begin,$end,$event_type) {
>  $a = array('unix_time' => $begin,
>   'event_type' => $event_type);
>   return $a;
>}
>
>for ($i = 0; $i < count($results) - 1; $i++) {
>                 $a =
>returnItem($results[$i],$results[$i+1],$results[$i]['event_type']);
>                 $structure []= $a;

Thus, when you pass the values to the function, $results[$i] and
$results[$i+1] are arrays. It looks like you should be doing:

returnItem($results[$i]['unix_time'], [value missing here],
$results[$i]['event_type']);


::::::::::::::::::::::::::::::::::
Howard Cheng
http://www.howcheng.com/
howcheng at ix dot netcom dot com
AIM: bennyphoebe
ICQ: 47319315




More information about the thelist mailing list