|
mysqli_result::fetch_assocmysqli_fetch_assocFetch a result row as an associative array DescriptionObject oriented style
array mysqli_result::fetch_assoc
( void
)
Procedural style
array mysqli_fetch_assoc
( mysqli_result
$result
)
Returns an associative array that corresponds to the fetched row or
Parameters
Return Values
Returns an associative array of strings representing the fetched row in the result
set, where each key in the array represents the name of one of the result
set's columns or If two or more columns of the result have the same field names, the last column will take precedence. To access the other column(s) of the same name, you either need to access the result with numeric indices by using mysqli_fetch_row or add alias names. ExamplesExample #1 Object oriented style
<?php Example #2 Procedural style
<?php The above examples will output: Pueblo (USA) Arvada (USA) Cape Coral (USA) Green Bay (USA) Santa Clara (USA) Example #3 A mysqli_result example comparing iterator usage
<?php The above example will output something similar to: 'root'@'192.168.1.1' 'root'@'127.0.0.1' 'dude'@'localhost' 'lebowski'@'localhost' ================== 'root'@'192.168.1.1' 'root'@'127.0.0.1' 'dude'@'localhost' 'lebowski'@'localhost' See Also
|