Is there any difference of any kind between $result->fetch_assoc()
and
$result->fetch_array(MYSQLI_ASSOC)
or they are exactly the same thing?
I have searched a bit before making this question but the only thing I've found (here) is that $result->fetch_array()
with no params allows numeric and associative indexes while
$result->fetch_assoc()
only allows the associative indexes and therefore the last one has a better performance.
Have you read the documentation of
mysqli_result::fetch_assoc()
andmysqli_result::fetch_array()
?The last one explains the possible values for its argument:
Yes, purpose and returned formats.
fetch_array()
has more output formats. You can see here PHP Manual : mysqli_result::fetch_array.Whereas PHP Manual : mysqli_result::fetch_assoc() outputs a single format.
fetch_array() is used when you need access to both associative and numeric indexes.
Use fetch_assoc() when you only need associative indexes.
Php.net docs say
Php.net fetch_array() description