[英]How can i get list of values from array in laravel?
I have array
such as below 我有如下
array
Array ( [0] => 2 [1] => 4 [2] => 5)
In which 2,4,5
is value and i need only list of value like [2,4,5]
is it possible in laravel?? 在其中
2,4,5
是值,我只需要像[2,4,5]
这样的值列表,在laravel中可能吗?
$list=[];
$arr=array( 0=> 2,1 => 4,2 => 5);// This is the original array
foreach($arr as $k=>$v ){
array_push($list,$v);
}
// Now,$list is what you need! [2,4,5]
I don't think this question is about laravel, this is basic knowledge of PHP array! 我不认为这个问题与laravel有关,这是PHP数组的基础知识!
使用以下命令获取列表。
implode(',', $array);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.