2017-04-16 48 views
0

我兩天,我正在嘗試解決這些錯誤, 公告:未定義抵消:1線230Errore未定義抵消:1個尼洛腳本

注意:未定義指數:上線231

$righi = file($txt); 
    foreach($righi as $id => $player){ 
    list($name, $position) = explode(">", $player); 
    $weighted[$weights[trim($position)]] = trim($player); 
+1

請使用英文 – OldPadawan

回答

1

使用isset,例如:

if(isset($weighted[$weights[trim($position)]])){ 
    // your code 
} 
+0

謝謝,但是我需要輸入你建議的功能,我非常不切實際的php,耐心等待,謝謝。 – Michael

+0

if(isset($ weighted [$ weights [trim($ position)]])){ $ weighted [$ weights [trim($ position)]] = trim($ player); } – RoboNoob

0
$righi = file($txt); 
    foreach($righi as $id => $player){ 
    list($name, $position) = explode(">", $player); 
    if(isset($weighted[$weights[trim($position)]])){ 
    $weighted[$weights[trim($position)]] = trim($player); } 


//sort by keys (reverse order ... descending) 
krsort($weighted); 
//overwrite original file 
file_put_contents($txt, $comment . implode(PHP_EOL, $weighted)); 
?> 

解析錯誤:語法錯誤,對意外的文件結束行240