Joe
Joe

Reputation: 3

Which should I use: mysql_fetch_array or mysql_fetch_assoc?

In other people's code I see both being used. So when retrieving database records, which should be used and when?

Upvotes: 0

Views: 432

Answers (2)

Felix Geenen
Felix Geenen

Reputation: 2707

just a note:

there are some other functions to get the results of your query like:

  • mysql_fetch_row and
  • mysql_fetch_object

Felix

Upvotes: 1

E.Benoît
E.Benoît

Reputation: 806

mysql_fetch_array() is more generic than mysql_fetch_assoc(), although it can generate the exact same results using proper parameters.

However, if you only need an associative array, I would advise you to use the latter, as the former makes the code more ambiguous or heavy, depending on how you use it.

Upvotes: 3

Related Questions