0
我錯過了什麼,也試圖給函數的參數和插入$ poolstale_enc_json,但這也給錯誤?如何將son_decode數組直接放入函數?
$poolstale_get_json = file_get_contents('../scripts/PoolStale');
$poolstale_enc_json = json_decode($poolstale_get_json);
$poolstale_enc_val = array();
$poolstale_enc_date = array();
function get_val_value(){
foreach($poolstale_enc_json as $tmp){
array_push($poolstale_enc_val,$tmp[1]);
// print_r($poolstale_enc_val); echo "</br>";
}
return $poolstale_enc_val;
}
function get_val_date(){
foreach($poolstale_enc_json as $tmp){
array_push($poolstale_enc_date,$tmp[2]);
// print_r($poolstale_enc_date); echo "</br>";
}
return $poolstale_enc_date;
}
get_val_date();
的錯誤是:
Notice: Undefined variable: poolstale_enc_json in /opt/lampp/htdocs/scripts/chart-data.php on line 90
Warning: Invalid argument supplied for foreach() in /opt/lampp/htdocs/scripts/chart-data.php on line 90
Notice: Undefined variable: poolstale_enc_date in /opt/lampp/htdocs/scripts/chart-data.php on line 94
好,我會再次嘗試,因爲我已經做到這一點,但我覺得我爲應對 – 4M8B
$ poolstale_enc_val =陣列有點困;-)感謝(); $ poolstale_enc_date = array();那些必須在功能內部就是解決方案 – 4M8B