Reputation: 27125
This post gives four ways of retrieving the result of a MySQL query:
mysqli_fetch_array
— Fetch a result row as an associative, a numeric array, or both
$row = mysqli_fetch_array($result);
echo $row[0]; // or
echo $row['online'];
mysqli_fetch_assoc
— Fetch a result row as an associative array
$row = mysqli_fetch_assoc($result);
echo $row['online'];
mysqli_fetch_object
— Returns the current row of a result set as an object
$row = mysqli_fetch_object($result);
echo $row->online;
mysqli_fetch_row
— Get a result row as an enumerated array
$row = mysqli_fetch_row($result);
echo $row[0];
Is there any significant difference between these four functions, in terms of either performance or functionality, or can they be used interchangeably?
Upvotes: 12
Views: 26896
Reputation: 157940
Is there any significant difference between these four functions
No.
can they be used interchangeably?
Yes.
Upvotes: 15