I am building a function which I want to retrieve key/value pairs from db, and it comes like $result=array($key=>$value); and when I use this $result, in an object requiring an array in its parameters
function Foo($result) { array ('superkey'=>$result); }
this considers that $result contains multiple arrays like this:
Array
(
[key1] => value1
)
Array
(
[key3] => value2
)
Array
(
[key3] => value3
)
Array
(
[key4] => value4
)
But I want it to consider it as one array:
Array
(
[key1] => value1
[key3] => value2
[key3] => value3
[key4] => value4
)
Can any one help me out?
When you retrieve values from a database, it usually sends a multi-dimensional array like:
The keys of these arrays are always the same, because they represent the column name from the database. It sounds to me like you’re looking for a way to compile all those values into a single array. To do that, you need to forget about the key, and use something ike this: