After implementing database queries, I am getting the multi-dimensional array below.
Two Dimensional Array
Array
(
[0] => Array
(
[t1] => test1
)
[1] => Array
(
[t2] => test2
)
[2] => Array
(
[t3] => test3
)
[3] => Array
(
[t4] => test4
)
[4] => Array
(
[t5] => test5
)
)
but I want to convert it to a single dimensional array, like the format below.
One Dimensional Array
Array (
t1 => test1
t2 => test2
t3 => test3
t4 => test4
t5 => test5
)
Please help me to do so
I think you can use array_reduce() function. For example:
pls fill $key['name given in sql query for field'] and $value['name given in sql query for field'] (both are same)
Please try this function:
Use this function:
Hope, this may be useful for you.
Try array map function.
This will do the trick
Note: This function array_column introduced in PHP 5.5 so it won't work in earlier versions.
You can use this