mysqli_fetch_assoc returns multiple arrays, how to return a single array


Posted on 16th Feb 2014 07:03 pm by admin

Hello, I am using mysqli_fetch_assoc which is returning multiple rows, so it looks like:

Code: [Select]while($row = mysqli_fetch_assoc($result)) {
print_r($row);
}

But this returns multiple arrays like:

Code: [Select]Array ( [key] => air_conditioning [label] => Air Conditioning ) Array ( [key] => balcony [label] => Balcony ) Array ( [key] => cable [label] => Cable ) Array ( [key] => cleaning_service [label] => Cleaning Service ) Array ( [key] => data_ports [label] => Data Ports ) Array ( [key] => dishwasher [label] => Dishwasher ) Array ( [key] => fireplace [label] => Fireplace ) Array ( [key] => fitness_center [label] => Fitness Center ) Array ( [key] => garage [label] => Garage ) Array ( [key] => hardwood_floors [label] => Hardwood Floors ) Array ( [key] => internet [label] => Internet ) Array ( [key] => jacuzzi [label] => Jacuzzi ) Array ( [key] => kitchen_island [label] => Kitchen Island ) Array ( [key] => ocean_view [label] => Ocean View ) Array ( [key] => paid_electricity [label] => Electricity ) Array ( [key] => paid_gas [label] => Gas ) Array ( [key] => paid_water [label] => Water ) Array ( [key] => pool [label] => Pool ) Array ( [key] => refrigerator [label] => Refrigerator ) Array ( [key] => secured_entry [label] => Secured Entry ) Array ( [key] => security_system [label] => Security System ) Array ( [key] => stove [label] => Stove ) Array ( [key] => tennis_court [label] => Tennis Court ) Array ( [key] => underground_parking [label] => Underground Parking ) Array ( [key] => walk_in_closets [label] => Walk In Closets ) Array ( [key] => washer_and_dryer [label] => Washer and Dryer ) Array ( [key] => yard [label] => Yard )

Is there a way to return a single array like:

Code: [Select]array(air_conditioning => Air Conditioning, balcony => Balcony, cable => Cable, etc...)

Thanks.

No comments posted yet

Your Answer:

Login to answer
203 Like 34 Dislike
Previous forums Next forums
Other forums

Output Full URL of Current Page
Let's say I am currently viewing a dynamic page:

http://www.mydomain.com/directory/index.php

OPINIONS WANTED
This is my login page code, and I want your opinion on it please!

Code: // Login ~ CHECKS

Intrastat Report Config in ECC 6.0 - goods Movement in EU countries
Colleagues, need ur help to understand the changes require in ECC 6 standard Report configuration se

losing session vars when arriving from an email link
Hi,

I've got a confirmation script made that sends an email with a link for a user to confirm

Streaming local file from PHP while it’s been written to by a CURL process
I am creating a simple Proxy server for my website. Why I am not using mod_proxy and mod_cache is a

Forms Authentication and Refresh at Login page
Hello, When I try to press the Login button in my webapplication at my login.aspx page nothing h

CHECK A STRING FOR ' " ' (DOUBLE QUOTES)
I am checking for delimiter (.!?) and if there is a " after a sentence then it should neglect a

Consuming MII WebService in Java WebDynpro
Hello,

We are facing a strange situation...

We define a transaction in MII to

Internal class functions don't seem to get executed.
Hi. Can someone please put me out of my misery on this. I don't write much PHP and this has me baffl

Using Microsoft Exchange Server with PHP
Hi,

I wanted to know if its possible to fetch email attachments from the exchange server usin

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash