note 108543 deleted from function.preg-match-all by danbrown
| From: | danbrown@php.net | Date: | Thu, 10 May 2012 16:48:57 +0000 |
| Subject: | note 108543 deleted from function.preg-match-all by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-187594@lists.php.net to get a copy of this message | ||
Note Submitter: nickleefly at hotmail dot com
----
a few lines of code to make a url into a clickable link using lazy star (.*?) and
$0 <?php $string = \'http://www.example.com www.example.com hahahaha https://www.example.com\'; $string
= $string.\" \"; $stringall =
preg_replace(\'/((https:\\/\\/)|(http:\\/\\/)|(www\\.))(.*?)(?=\\s)/i\',\'<a
href=\"$0\"
target=\"_blank\">$0</a>\',$string); $stringallc
= preg_replace(\'/(href=\\\"www\\.)/i\',\'href=\"http://www.\',$stringall); echo
$stringallc; ?>