文字列の例で URL を変更するにはどうすればよいですか :
これはリンクです<a href="http://google.com.au">http://google.com.au</a>
このようなものに
これは警告ページのリンクです<a href="./warn.php?link=http://google.com.au">http://google.com.au</a>
編集:
私がやろうとしているのは、エンド ユーザーが入力した説明を取得することです。彼らは説明にリンクを入力する可能性があります。すべてのリンクを変更して、警告ページに移動したいのですが、警告ページは./warn.php?site=link
文字列は次のようになります
This is a awesome description <a href="google.com.au">Google</a> and this another link <a href="http://google.com.au/images">Google images</a>
これが私が試したことです:
$descc = mysql_real_escape_string($_POST['description']);
$descc = preg_replace('"\b(http://\S+)"', '<a href="./warn.php?site='.base64_encode(.'$1'.).'">$1</a>', $descc);