P
P
Peter2015-09-27 12:45:37
PHP
Peter, 2015-09-27 12:45:37

How to get from the database (mysqli) all records in the form of associative arrays?

There is a database:
id, foo, bar
1,1,1
2,2,2
I want to get an array:
[0]=>['id'=>1,'foo'=>1,'bar'=>1]
[ 1]=>['id'=>2,'foo'=>2,'bar'=>2]
mysqli_fetch_all returns non-associative arrays. I can't find a suitable method.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Santiago K, 2015-09-27
@Alcospb

mysqli_fetch_all($res, MYSQLI_ASSOC);
php.net/manual/ru/mysqli-result.fetch-all.php

Y
Yuri Petrashevich, 2015-09-27
@BelCoder

php.net/manual/ru/function.mysql-fetch-assoc.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question