This article mainly shares with you several methods of converting mysql query results into PHP arrays. It is mainly shared with you in text form. I hope it can help you.
$result = mysql_fetch_row(): This function returns an array. The array is subscripted with numbers. You can only reference it in the form of $result[0], $Result[2].
$result = mysql_fetch_assoc(): This function returns an array subscripted by the field name, which can only be referenced by the field name.
$result['field1']. $result = mysql_fetch_array(): This function returns a mixed array that can be referenced either by numeric subscript or by field name.
$result[0] or $result["field1"]. $result = mysql_fetch_object(): Returns the result in the form of an object, which can be referenced in the form of $result->field1.
It is recommended to use mysql_fetch_assoc() or mysql_fetch_array. These two functions execute faster and can also be referenced through field names, which is clearer.
The above is the detailed content of Several ways to convert mysql query results into PHP arrays. For more information, please follow other related articles on the PHP Chinese website!