php 怎么读取数组中的指定值
Array([0]=>Array([.id]=>*1[name]=>ppp1[service]=>any[caller-id]=>[password]=>[profile...
Array ( [0] => Array ( [.id] => *1 [name] => ppp1 [service] => any [caller-id] => [password] => [profile] => default [routes] => [limit-bytes-in] => 0 [limit-bytes-out] => 0 [disabled] => false [comment] => ) [1] => Array ( [.id] => *2 [name] => ppp2 [service] => any [caller-id] => [password] => [profile] => default [routes] => [limit-bytes-in] => 0 [limit-bytes-out] => 0 [disabled] => false [comment] => ) [2] => Array ( [.id] => *3 [name] => ppp3 [service] => any [caller-id] => [password] => [profile] => default [routes] => [limit-bytes-in] => 0 [limit-bytes-out] => 0 [disabled] => false [comment] => ) )
上面这个数组,怎么能把所有name的值读取出来,整合成一个 一维数组?
新人,不太懂,大家多多指点 展开
上面这个数组,怎么能把所有name的值读取出来,整合成一个 一维数组?
新人,不太懂,大家多多指点 展开
4个回答
展开全部
$arr=array();
foreach($array as $value){
foreach($value as $key=>$val){
if($key=='name'){
$arr[]=$val;
}
}
}
var_dump($arr);
$array为你提供的数组。
foreach($array as $value){
foreach($value as $key=>$val){
if($key=='name'){
$arr[]=$val;
}
}
}
var_dump($arr);
$array为你提供的数组。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<?php
foreach ($array as $key => $value) {
foreach ($value as $k => $val) {
if ($k == 'name') {
$newArr[] = $val;
}
}
}
echo "<pre>";
print_r($newArr);
echo "</pre>";
?>
望采纳 Thx
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
foreach($arr as $key=>$val){
$new_arr[$key] = $val['name'];
}
$new_arr[$key] = $val['name'];
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询