したがって、いくつかの変更$_POST
を加えた後にから生成される次の配列があります。unset()
Array ( [actual-1] => 2 [target-1] => 4 [act-1] => dzdz [quarter-1] => 3 [year-1] => 2016 [actual-2] => 1 [target-2] => 3 [act-2] => zz [quarter-2] => 2 [year-2] => 2016 [actual-53] => 3 [target-53] => 2 [act-53] => zzd [quarter-53] => 1 [year-53] => 2015 [actual-58] => 5 [target-58] => 1 [act-58] => eec [quarter-58] => 2 [year-58] => 2013 )
次のコードを実行して値を抽出し、次の形式で表示します。
ID -- Level -- Action -- Target -- Action Quarter: -- Action year --
コード:
foreach(array_chunk($array,2,true) as $val) {
foreach($val as $k=>$v) {
if (strpos($k, "actual") !== false) {
$temp = explode("-",$k);
$id = $temp[1];
$actual = $v;
}
if (strpos($k, "act") !== false) {
$action = $v;
}
if (strpos($k,"target") !== false) {
$target= $v;
}
if (strpos($k, "quarter") !== false) {
$action_quarter = $v;
}
if(strpos($k, "year") !== false){
$action_year = $v;
}
}
echo "ID ".$id." Level ".$actual." action ".$action." Target: ".$target. " Action Quarter: ". $action_quarter. " Action year : ".$action_year;
echo "<br><--->";
}
しかし、私が得るのは次のoutput messing up the values
とおりです。
Notice: Undefined variable: action_quarter in C:\www\index\DevIT\classes\hr_competences.php on line 475
Notice: Undefined variable: action_year in C:\www\index\DevIT\classes\hr_competences.php on line 475
ID 1 Level 2 action 2 Target: 4 Action Quarter: Action year :
<--->
Notice: Undefined variable: action_year in C:\www\index\DevIT\classes\hr_competences.php on line 475
ID 1 Level 2 action dzdz Target: 4 Action Quarter: 3 Action year :
<--->ID 2 Level 1 action 1 Target: 4 Action Quarter: 3 Action year : 2016
<--->ID 2 Level 1 action zz Target: 3 Action Quarter: 3 Action year : 2016
<--->ID 2 Level 1 action zz Target: 3 Action Quarter: 2 Action year : 2016
<--->ID 53 Level 3 action 3 Target: 2 Action Quarter: 2 Action year : 2016
<--->ID 53 Level 3 action zzd Target: 2 Action Quarter: 1 Action year : 2016
<--->ID 58 Level 5 action 5 Target: 2 Action Quarter: 1 Action year : 2015
<--->ID 58 Level 5 action eec Target: 1 Action Quarter: 1 Action year : 2015
<--->ID 58 Level 5 action eec Target: 1 Action Quarter: 2 Action year : 2013