FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » mysql_fetch_array
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: mysql_fetch_array [message #169770 is a reply to message #169768] Sat, 25 September 2010 21:08 Go to previous messageGo to previous message
Marious Barrier is currently offline  Marious Barrier
Messages: 25
Registered: September 2010
Karma:
Junior Member
On 09/25/2010 04:28 PM, 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?

In PHP, if you don’t specify a key when adding values to an array, it
automatically appends a new key.

$arr = array('a', 'b', 'c');

$arr[] = 'd';

print_r($arr);



array(4)
{
0 => 'a',
1 => 'b',
2 => 'c',
3 => 'd'
}
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Group sort syntax?
Next Topic: Code to create a cookie in PHP
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 11:29:10 GMT 2024

Total time taken to generate the page: 0.03849 seconds