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

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?


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.




PHP General Mailing List (
To unsubscribe, visit:

Reply via email to