Published in: PHP
文字列中のURLとメールアドレスをリンクに変換する
/** * URLをリンクに変換する * @param string $content 変換する文字列 * @return stiring 変換後の文字列 */ function cnvUrlToLink($content){ $res=""; foreach($s as $line){ "/(https?:\/\/[\w\.\~\-\/\?\&\+\=\:\;\@\%\,]+)/", "/([\w\.\-_]+@[\w\-_]{2,}\.[\w\.\-_]{2,})/", ); "<a href=\"\${1}\">\${1}</a>", "<a href=\"mailto:\${1}\">\${1}</a>", ); } return($res); }
You need to login to post a comment.
