我需要将所有子数组Name
值加入单个子数组中。
给定输入格式:
Array
(
[0] => Array
(
[0] => Array
(
[Name] => kumar
)
[1] => Array
(
[Name] => siva
)
)
[1] => Array
(
[0] => Array
(
[Name] => Arun
)
[1] => Array
(
[Name] => Prem
)
)
)
所需的输出格式
Array
(
[0] => Array
(
[0] => Array
(
[Name] => kumar, siva
)
)
[1] => Array
(
[0] => Array
(
[Name] => Arun, Prem
)
)
)
我的编码尝试:
$final = array();
foreach ($NameArray as $row) {
foreach ($row as $rows) {
$final[] = $rows['Name'];
}
}
print_r($final);
它显示每个单独的。我需要每个子数组都是逗号格式的单个数组名称。