0
我有兩個陣列,我需要取決於$arr[0]["num"]
從數組中取出的值,並把該值到另一個數組
$arr = array(
0 => array(
"id" => 24,
"num" => 2
),
1 => array(
"id" => 25,
"num" => 5
)
2 => array(
"id" => 26,
"num" => 3
)
);
$array = array('1','2','3','4','5','6','7','8','9','10');
$new = array();
foreach($arr as $key){
for($i=0;$i<$key['num'];$i++){
$new[$key['id']][$i] = $array[$i];
}
}
的值,以提取第二數組的值是它能夠去除第二個數組的值,並將其轉移到一個新的數組?
我的循環所做的只是在每個循環之後從開始複製值。我想從第二個數組中刪除複製的值。
輸出應該是這樣的:
Array
(
[24] => Array
(
[0] => 1
[1] => 2
)
[25] => Array
(
[0] => 3
[1] => 4
[2] => 5
[3] => 6
[4] => 7
)
[26] => Array
(
[0] => 8
[1] => 9
[2] => 10
)
)
這爲我工作。謝謝! – addykha