運行下面的代碼:腓未定義,偏移誤差
preg_match("/^top\-sites\-csv\_(.+)\_/i", $file, $matches);
$site_id = $matches[1];
它不斷生成此通知:
PHP Notice: Undefined offset
我猜它發生時,正則表達式並沒有找到匹配。 問題是,腳本是在cron和我的錯誤日誌中沒有時間的增長巨大,則需要手動清潔..
運行下面的代碼:腓未定義,偏移誤差
preg_match("/^top\-sites\-csv\_(.+)\_/i", $file, $matches);
$site_id = $matches[1];
它不斷生成此通知:
PHP Notice: Undefined offset
我猜它發生時,正則表達式並沒有找到匹配。 問題是,腳本是在cron和我的錯誤日誌中沒有時間的增長巨大,則需要手動清潔..
其類似'preg_match($ pattern,$ subject,$ matches,PREG_OFFSET_CAPTURE,3);' –
添加一個if塊來查看數組鍵是否存在,if不是,替換其他的網站ID? – Daedalus
你可以做'if(preg_match($ pattern,$ text,$ matches))'來檢查是否有任何匹配。 – air4x