0

I was wondering that we have this function in PHP:

mysqli_fetch_row($result);

and this returns a simple array, but using it as an array like

mysqli_fetch_row($result)[0];

to get the first element of the array doesn't work, so you have to create a new variable which will contain the returned array.

Could anyone explain why isn't this working?

digitaltos
  • 85
  • 7

1 Answers1

0

Because mysqli_fetch_row is a function that returns a value - it's not an array itself.

Assigning a variable will retrieve the result. Unfortunately that's how it works in earlier versions of PHP.

Gerald's link identifies the functionality it as availble in PHP 5.4, so I guess that you're using an earlier version.

John Reid
  • 1,155
  • 10
  • 19