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
34
Other forums
PHP5 - Verifying a secure mail is secure
I need to send an e-mail from a form to a external department and because it contains personal custo
Which practice of iteration through containers is preferred
In the "real world" what kind of loop do most people use to iterate through a container like a vecto
A problem with my GD class
Hello,
I created a nice (and simple for now) GD class.
The problem is , it works great on
Multi-user card game
I'm writing a batch of games and such. Lottery is finished, Poker,blackjack,etc are next. They will
Working with popups and such in a class
I've recently started building my applications completely enclosed in classes. I like the fact that
Converting numbers to months
The porgram works -just need the last function(month_convert_ to convert numbers to months -thanks.
Printer configuration
Hi All,
Suppose one of the user deleted the printer settings unfortunatly ,then what is the pro
Php If in MySql query (hiding labels if a field is empty)
Okay, I've been trying to do this for a while, and I'm finally going to ask for help so I can get th
Help If user voted, block them
On my Prayer request site, i let users Click a button to Pray for somone that has posted a pray, i g
Get relative path from absolute path
How would one go about getting the relative path to a file from its absolute path?