What is so creative?

Automatic Link

 

PHPでデータに「http」が入っていたら自動リンクさせたいときメモ

<?php

$patterns = array("/(https?|ftp)(:\/\/[[:alnum:]\+\$\;\?\.%,!#~*\/:@&=_-]+)/i");

$replacements = array("<a href=\"\\1\\2\" target=\"_blank\">\\1\\2</a>");

$ret = preg_replace($patterns, $replacements, $lastpoints->datareference);

echo $ret;

?>

Comments

0 comments posted

Post new comment

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.