/ Published in: PHP
æ–‡å—列ä¸ã®URLã¨ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’リンクã«å¤‰æ›ã™ã‚‹
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * 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); }