/ Published in: Other
Expand |
Embed | Plain Text
$str = '<a href="/index.html" target="_blank">PHPリファンレンス</a>'; //大文字・小文字を区別してマッチングを行う場合 if( ereg( "href", $str ) ){ print "href にマッチしましたn"; } //大文字・小文字を区別しないでッチングを行う場合 if( eregi( "HREF", $str ) ){ print "HREF にマッチしました(大文字・小文字は無視)n"; } //後方参照を行うには、第三引数に配列変数を指定する if( ereg( "href="([^"]*)" target="([^"]*)"", $str, $matches) ){ for( $i = 0; $i < count($matches); $i++ ){ print $matches[$i] . "n"; //結果は以下の順に出力される //href="/index.html" target="_blank" ///index.html //_blank } }
You need to login to post a comment.
