我得到了这样的查询结果: -
Array(
[0] => Array
(
[0] => Array
(
[id] => 1
[name] => Japan
)
)
[1] => Array
(
[0] => Array
(
[id] => 2
[name] => Nepal
)
)
}
如何将其转换为
Array
(
[0] => Japan
[1] => Nepal
)
用于获取第一个数组的查询是“select id,from country;” 请帮帮我。
答案 0 :(得分:0)
foreach ($element as $array) {
$element = $element[0]["name"];
}
或者,
function extractName($element) {
return $element[0]["name"];
}
$newArray = array_map("extractName", $array);
答案 1 :(得分:0)