At 3:31 PM -0500 9/25/10, MikeB wrote:
-snip-

My question, in the loop, why does tha author use:

$results[] = mysql_fetch_array($result);

instead of (as I would expect):

$results[$j] = mysql_fetch_array($result);?

What PHP magic is at work here?

Mike:

That's just a shorthand way to populate an array in PHP.

One of the reasons for this feature is that somewhere in your code you may not know what the next index should be. So, if you use --

$results[] = $next_item;

-- then the $next_item will be "automagically" added to the next available index in the array. So you may be right in calling it "PHP magic" because I have not seen this in other languages.

Understand?

Cheers,

tedd
--
-------
http://sperling.com/

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

Reply via email to