PHP 2 dim Array to 1 dim array -
is there built in function following?
$a[] = $b[0]['foo']; $a[] = $b[1]['foo']; $a[] = $b[2]['foo']; etc.. i realize can following:
foreach($b $c) { $a[] = $c['foo']; } but curious if there built in array function this. thanks.
in short: no.
in long: maybe ;) because not "directly built-in"
with php5.3
$a = array_map (function ($entry) { return $entry['foo']; }, $b); or before
$a = array_map (create_function ('$entry', 'return $entry[\'foo\'];'), $b); at least second solution prefer foreach-loop ;)
Comments
Post a Comment