array(
1 => array(
"name" => "n1",
"desc" => "desc1"
),
2 => array(
"name" => "n2",
"desc" => "desc2"
)
)
array(
"name" => array("n1", "n2"),
"desc" => array("desc1", "desc2")
)
$arr = array(
1 => array(
"name" => "n1",
"desc" => "desc1"
),
2 => array(
"name" => "n2",
"desc" => "desc2"
),
3 => array(
"name" => "n3",
"desc" => "desc3"
)
);
$result = array(
'name' => array_column($arr, 'name'),
'desc' => array_column($arr, 'desc')
);
var_dump($result);
array (size=2)
'name' =>
array (size=3)
0 => string 'n1' (length=2)
1 => string 'n2' (length=2)
2 => string 'n3' (length=2)
'desc' =>
array (size=3)
0 => string 'desc1' (length=5)
1 => string 'desc2' (length=5)
2 => string 'desc3' (length=5)