what is the easiest way to change this array to 1D array, i can do that using for loop or foreach, but i’m curious to check if there is an easier way. THANKS
Array
(
[0] => Array
(
[id] => 1
)
[1] => Array
(
[id] => 2
)
[2] => Array
(
[id] => 3
)
)
The
array_shift()function grabs the first key/val pair out of an array and returns the value, so applying it to each of the arrays in your top-level array, and combining the results, will result in a 1-d list of the id’s.If your arrays actually have more info than just the id field in them, then you’d probably want to define a function that specifically pulls out whatever field(s) you want and returns those, and then use that function with
array_map.