$result =
Array
(
[0] => Array
(
[0] => 4
[1] => 4
[2] => 4
[3] => 4
[4] => 4
[5] => 4
[6] => 4
[7] => 4
[8] => 4
[9] => 4
[10] => 40
)
[1] => Array
(
[0] => 5
[1] => 4
[2] => 4
[3] => 4
[4] => 4
[5] => 4
[6] => 4
[7] => 4
[8] => 4
[9] => 4
[10] => 41
)
[2] => Array
(
[0] => 5
[1] => 5
[2] => 5
[3] => 5
[4] => 5
[5] => 5
[6] => 5
[7] => 5
[8] => 5
[9] => 5
[10] => 50
)
)
这就是我想要转化为:
在array_merge之后:
$result =
Array
(
[0] => 4
[1] => 4
[2] => 4
[3] => 4
[4] => 4
[5] => 4
[6] => 4
[7] => 4
[8] => 4
[9] => 4
[10] => 40
[11] => 5
[12] => 4
[13] => 4
[14] => 4
[15] => 4
[16] => 4
[17] => 4
[18] => 4
[19] => 4
[20] => 4
[21] => 41
[22] => 5
[23] => 5
[24] => 5
[25] => 5
[26] => 5
[27] => 5
[28] => 5
[29] => 5
[30] => 5
[31] => 5
[32] => 50
)
这是代码:
<?php
$result = array();
?>
@foreach ($detail_ratings as $detail_rating)
<?php $result[] = json_decode($detail_rating); ?>
@endforeach
<?php
$result = array_merge($result[0],$result[1],$result[2]);
?>
{{print_r($result)}}
如何在不手动使用此代码的情况下自动创建:
$result = array_merge($result[0],$result[1],$result[2]);
这就是我已经做过的事情:
foreach ($result as $key => $value) {
$values[] = array_merge($value,$result[$key]);
}
答案 0 :(得分:0)
也许这可以提供帮助: -
function nameit(array $arr)
{
$newarr = array();
foreach($arr as $a => $b)
{
$newarr[] = $b;
}
return $newarr;
}
答案 1 :(得分:0)
使用此
$result=array();
foreach($values as $value) {
$result = array_merge($result,$value);
}
答案 2 :(得分:0)
试试这个:
$final_array = array_merge($array1,$array2);