Array question
| From: | MikeB | Date: | Sat, 25 Sep 2010 20:31:19 +0000 |
| Subject: | Array question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-308313@lists.php.net to get a copy of this message | ||
I have the following code:
$query = "SELECT * FROM classics";
$result = mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result);
for ($j = 0 ; $j < $rows ; ++$j)
{
$results[] = mysql_fetch_array($result);} mysql_close($db_server); 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? Thanks.