$arr1 = Array ( [0] => 5 [days] => 5 )
Array ( [0] => 6 [days] => 6 )
Array ( [0] => 7 [days] => 7 )
Array ( [0] => 8 [days] => 8 )
Array ( [0] => 9 [days] => 9 )
Array ( [0] => 10 [days] => 10 )
Array ( [0] => 11 [days] => 11 )
Array ( [0] => 12 [days] => 12 )
Array ( [0] => 13 [days] => 13 )
Array ( [0] => 14 [days] => 14 )
Array ( [0] => 15 [days] => 15 )
Array ( [0] => 16 [days] => 16 )
Array ( [0] => 17 [days] => 17 )
Array ( [0] => 18 [days] => 18 )
Array ( [0] => 19 [days] => 19 )
Array ( [0] => 20 [days] => 20 )
Array ( [0] => 21 [days] => 21 )
Array ( [0] => 22 [days] => 22 )
Array ( [0] => 23 [days] => 23 )
Array ( [0] => 24 [days] => 24 )
Array ( [0] => 25 [days] => 25 )
Array ( [0] => 26 [days] => 26 )
Array ( [0] => 27 [days] => 27 )
Array ( [0] => 28 [days] => 28 )
Array ( [0] => 29 [days] => 29 )
Array ( [0] => 30 [days] => 30 )
Array ( [0] => 31 [days] => 31 );
$arr2 = Array ( [0] => 1 [day] => 1
[1] => 1 [days] => 1 )
Array ( [0] => 2 [day] => 2 [1] => 2 [days] => 2 ) Array ( [0] => 3 [day] => 3 [1] => 3 [days] => 3 ) Array ( [0] => 4 [day] => 4 [1] => 4 [days] => 4 );
我想提升$arr1
和$arr2
以及我希望的输出
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
帮帮我,我该怎么做?
答案 0 :(得分:1)
试试这段代码
<?php
$arr1 = Array(0=>Array ( 0 => 5 ,'days' => 5 ) ,
1=>Array ( 0 => 6 ,'days' => 6 ),
2=>Array ( 0 => 7 ,'days' => 7 ),
3=>Array ( 0 => 8 ,'days' => 8 ),
4=>Array ( 0 => 9, 'days' => 9 ),
5=>Array ( 0 => 10, 'days' => 10 ),
6=>Array ( 0 => 11, 'days' => 11 ),
7=>Array ( 0 => 12, 'days' => 12 ),
8=>Array ( 0 => 13, 'days' => 13 ),
9=>Array ( 0 => 14, 'days' => 14 ),
10=>Array ( 0 => 15, 'days' => 15 ),
11=>Array ( 0 => 16, 'days' => 16 ),
12=>Array ( 0 => 17, 'days' => 17 ),
13=>Array ( 0 => 18, 'days' => 18 ),
14=>Array ( 0 => 19, 'days' => 19 ),
15=>Array ( 0 => 20, 'days' => 20 ),
16=>Array ( 0 => 21, 'days' => 21 ),
17=>Array ( 0 => 22, 'days' => 22 ),
18=>Array ( 0 => 23, 'days' => 23 ),
19=>Array ( 0 => 24, 'days' => 24 ),
20=>Array ( 0 => 25, 'days' => 25 ),
21=>Array ( 0 => 26, 'days' => 26 ),
22=>Array ( 0 => 27, 'days' => 27 ),
23=>Array ( 0 => 28, 'days' => 28 ),
24=>Array ( 0 => 29, 'days' => 29 ),
25=>Array ( 0 => 30, 'days' => 30 ),
26=>Array ( 0 => 31 ,'days' => 31 ));
$arr2 = Array(0=>Array( 0 => 1, 'day' => 1, 1 => 1, 'days' => 1 ) ,
1=> Array ( 0 => 2, 'day' => 2, 1 => 2, 'days' => 2 ) ,
3=>Array ( 0 => 3, 'day' => 3, 1 => 3 ,'days' => 3 ) ,
4=>Array ( 0 => 4 ,'day' => 4, 1 => 4 ,'days' => 4 ));
foreach ($arr2 as $key => $value) {
$arr2[$key]=array_unique($value);
}
foreach ($arr1 as $key => $value) {
$arr1[$key]=array_unique($value);
}
$new=array_merge($arr2,$arr1);
foreach ($new as $key => $value) {
foreach ($value as $key1 => $value1) {
echo $value[0].",";
}
}
?>
答案 1 :(得分:0)
您可以使用 array_column 从多维数组中仅选择天,然后使用 array_merge 合并数组。
就像这样
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<ul class="breadcrumb">
<li><a href="#">MEP SERVICES</a></li>
<li><a href="#">electrical</a></li>
<li><a href="#">lighting</a></li>
<li>HT & LT</li>
</ul>
它会产生你想要的输出。