ラインを持つ
(01) Some text
(10) Foo Bar
(11) ?
(13) Foo Bar
(13) ?
(20) Something else
4行をまとめてチェック。行 1 と 3 が同じで、行 2 と 4 が(XX) ?
である場合、行 2 ~ 4 を に置き換え...
て、
(01) Some text
(10) Foo Bar
...
(20) Something else
コード:
$arr = explode("\n", $t);
if ( count($arr) > 3 ) {
for ($i=1; $i<count($arr); $i++) { // check 4 rows
if( ($arr[$i-1] == $arr[$i+1]) // if row 1 and 3 are the same
&& preg_match('/\(\d+\) \?$/', $arr[$i]) // and row 2 is "(XX) ?"
&& preg_match('/\(\d+\) \?$/', $arr[$i+2]) // and row 4 is "(XX) ?"
) {
print "Match!"; //test. later replace rows 2-4 with a row "..."
}
}
}
これにより、現在オフセットエラーが発生します。
テスト: http://codepad.viper-7.com/iMO3BW
これはどのように解決できますか?