我試圖讓的形式從一個數組數據:提取數據正確
Array ([actual-1] => 2 [action-1] => blabla [actual-2] => 1 [action-2] => sss [actual-49] => 3 [action-58] => sasa)
ID 1 Level 2 action blabla
ID 2 level 1 action sss
ID 49 level 3 action sasa
我嘗試下面的代碼:
foreach(array_chunk($array,3,true) as $val){
foreach($val as $k=>$v){
if(strpos($k, "actual") !== false){
$temp = explode("-",$k);
$id = $temp[1];
$actual = $v;
}
if(strpos($k, "action") !== false){
$action = $v;
}
}
echo "ID ".$id." Level ".$actual." action ".$action;
echo "<br>";
}
但我得到的卻是:
ID 2 Level 1 action blabla
ID 49 level 3 action sasa
天才;謝謝:) – auicsc
沒問題@auicsc。不要忘記接受最能幫助你的答案。 –