我想在循环外使用我的新数组。我该怎么做?$new = array();foreach ($array as $data) { $url = $data["result"]["url"]; $name = $data["result"]["name"]; $new = array( $name => $url );}print_r($new);
1 回答
守候你守候我
TA贡献1802条经验 获得超10个赞
代替
$new = array(
$name => $url
);
将其编辑为
$new[$name] = $url;
所以最后会是这样
$new = array();
foreach ($array as $data) {
$url = $data["result"]["url"];
$name = $data["result"]["name"];
$new[$name] = $url;
}
print_r($new);
- 1 回答
- 0 关注
- 105 浏览
添加回答
举报
0/150
提交
取消