我的数组名为$email_ids
Array
(
[0] => Array
(
[user_email] => abc@gmail.com
)
[1] => Array
(
[user_email] => lmn@gmail.com
)
[2] => Array
(
[user_email] => pqr@gmail.com
)
)
我想以followinf格式将其转换为数组:
Array
(
[0] => abc@gmail.com
[1] => lmn@gmail.com
[2] => pqr@gmail.com
)
我应该如何以最佳方式获得这个?
答案 0 :(得分:2)
array_map(function($x){return $x['user_email'];}, $email_ids)
答案 1 :(得分:1)
使用简单的foreach
$newarr = array();
foreach($yourarray as $k=>$arr)
{
$newarr[]=$arr['user_email'];
}
答案 2 :(得分:1)
试试这个
$temp = array();
foreach($arr as $val){
$temp[] = $val['user_email'];
}
var_dump($temp);