|
mysqli_result::fetch_assocmysqli_fetch_assocFetch the next row of a result set as an associative array DescriptionObject-oriented style
public arraynullfalse mysqli_result::fetch_assoc()
Procedural style arraynullfalse mysqli_fetch_assoc(mysqli_result
$result )
Fetches one row of data from the result set and returns it as an associative
array.
Each subsequent call to this function will return the next row within the
result set, or If two or more columns of the result have the same name, the last column will take precedence and overwrite any previous data. To access multiple columns with the same name, mysqli_fetch_row may be used to fetch the numerically indexed array, or aliases may be used in the SQL query select list to give columns different names.
Parameters
Return Values
Returns an associative array representing the fetched row,
where each key in the array represents the name of one of the result
set's columns, ExamplesExample #1 mysqli_result::fetch_assoc example Object-oriented style
Procedural style
The above examples will output something similar to: Pueblo (USA) Arvada (USA) Cape Coral (USA) Green Bay (USA) Santa Clara (USA) Example #2 Comparison of mysqli_result iterator and mysqli_result::fetch_assoc usage mysqli_result can be iterated using foreach. The result set will always be iterated from the first row, regardless of the current position.
The above example will output something similar to: Pueblo (USA) Arvada (USA) Cape Coral (USA) Green Bay (USA) Santa Clara (USA) ================== Pueblo (USA) Arvada (USA) Cape Coral (USA) Green Bay (USA) Santa Clara (USA) See Also
|