28

How can I only fetch one INDEXED row with MySQLi? I'm currently doing this:

$row = $result->fetch(MYSQLI_ASSOC);
$row = $row[0];

Is there another way?

I'm aware of mysqli_fetch_row but it doesn't return an associative array.

oaziz
  • 1,362
  • 1
  • 17
  • 32

1 Answers1

56

Use $row = $result->fetch_assoc(); - it's the same as fetch_row() but returns an associative array.

Tim
  • 2,563
  • 1
  • 23
  • 31
You Qi
  • 8,353
  • 8
  • 50
  • 68