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);
Did you know?Explore Trending and Topic pages for more stories like this.
}

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

php libs/ browsercap.in
ok i have a host that refuses to stay current. they control my php settings and libs. is there a way

How to write on database when a link is clicked?
Hi, I have a list of products in a gridview. When the link is clicked currently it takes to an ext

How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........

header redirect problems? please help
Ok i am making a site that generates youtube thumbnails and i am generating an image that displays 1

unoconv doc convert to pdf code prob
PHP/5.3.1

Hi. I am trying to use this code to convert docs to .pdf utilizing unoconv. Howe

Transform value 0 in no and 1 in yes help needed
Hello,
I have this in the table: "value" type int 0 to represent false and 1 to represe

form class help (oop php5)
Hidy Ho Neighbors,

I'm forcing myself to learn oop/classes for php5. It seems like a good id

Print out contents of to Excel
I have got this script that gathers all the data that I need but I need it to send it to excel inste

Multiple server callbacks (NOT POSTBACKS)
Hello, I have 2 different javascript client side functions that are on timers. When the timers elap

Rand() help needed
Hi all,

Can someone explain and give me a quick example of how I would go about this?

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