$ results包含3个单维数组
Array ( [0] => http://ecx.images-amazon.com/images/I/51z0h9unmsL._SL160_.jpg)
Array ( [0] => http://ecx.images-amazon.com/images/I/51z0h9unmsL._SL160_.jpg)
Array ( [0] => http://ecx.images-amazon.com/images/I/51z0h9unmsL._SL160_.jpg)
我想要一个结果:
Array ( [0] => http://ecx.images-amazon.com/images/I/51z0h9unmsL._SL160_.jpg)
Array ( [1] => http://ecx.images-amazon.com/images/I/51z0h9unmsL._SL160_.jpg)
Array ( [2] => http://ecx.images-amazon.com/images/I/51z0h9unmsL._SL160_.jpg)
答案 0 :(得分:1)
解决方案1:
$new_array = array();
foreach($results as $key => $value){
$new_array[] = $value[0];
}
或:
$new_array = array();
foreach($results as $key => $value){
$new_array[] = $value;
}
但第一种解决方案更好,因为您的数组包含每个值的单个值。
答案 1 :(得分:1)
使用array_merge
$arr1=array("http://ecx.images-amazon.com/images/I/51z0h9unmsL._SL160_.jpg");
$arr2=array("http://ecx.images-amazon.com/images/I/51z0h9unmsL._SL160_.jpg");
$arr3=array("http://ecx.images-amazon.com/images/I/51z0h9unmsL._SL160_.jpg");
$arr=array_merge($arr1,$arr2,$arr3);