I have an array like this:
$a = array(
array(
'a' => 'x',
'b' => 'asdasd',
),
array(
'a' => 'f',
'b' => '123123qwe',
),
);
And I expect an array like this:
$a = array(
'asdasd',
'123123qwe',
);
I can transform this by iterating and filling a new array, I wonder if I can do this in 1 line without temporary variables?
Update: Using PHP 5.3 , thanks for the 5.5 suggestions tho!
If you're using PHP 5.5 you can use array_column():
$new_array = array_column($a, 'b');
See it in action
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With