Question:

Which function is used to fetch a single row from a MySQL query result as an associative array?

Show Hint

The word assoc in the name signals column-name keys, which is what associative means.
Updated On: Jul 2, 2026
  • mysqli_fetch_row()
  • mysqli_fetch_array()
  • mysqli_fetch_assoc()
  • mysqli_fetch_object()
Show Solution
collegedunia
Verified By Collegedunia

The Correct Option is C

Solution and Explanation

Step 1: The question asks specifically for an associative array, meaning keys are the column names.

Step 2: mysqli_fetch_row() returns a plain numeric array, keyed 0, 1, 2. That is not associative.

Step 3: mysqli_fetch_object() returns an object, so you use $row->col, not array keys.

Step 4: mysqli_fetch_array() can return numeric, associative or both, but the function meant purely for an associative array is mysqli_fetch_assoc(). It returns one row where each value is indexed by its column name.

So the answer is option C.
Was this answer helpful?
0
0