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?
Is there any significant difference between these four functions
No.
can they be used interchangeably?
Yes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With