John Nichel wrote:

John W. Holmes wrote:


Change that to:

$array = array();
$results  = mysql_query( $sql, DB::connect() );
while($data = mysql_fetch_array($result))
{ $array[] = $data; }

return $array;


Would there be any speed/performance issuse with using something like...

array_push ( $array, $data );

vs.

$array[] = $data;

I'd say the main performance hit with this approach is that we need to (indirectly) iterate over the resultset twice. First we go into a loop to do the actual retrieval and chuck in into the array. Then we usually need to go into another loop to see what we have in the array.


As you mentioned in your follow up mail the difference between array_push() and $array[]=.. is neglible similarly in most cases, looping twice will not have a significant impact - unless of course you are looping through a really large resultset and don't have a lot of memory to spare.



--
Raditha Dissanayake.
------------------------------------------------------------------------
http://www.radinks.com/sftp/         | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.

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



Reply via email to