note 108543 added to function.preg-match-all
| From: | nickleefly at hotmail dot com | Date: | Sat, 05 May 2012 08:57:30 +0000 |
| Subject: | note 108543 added to function.preg-match-all | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-187481@lists.php.net to get a copy of this message | ||
a few lines of code to make a url into a clickable link
using lazy star (.*?) and $0
<?php
$string = 'http://www.haha.com www.haha.com hahahaha https://www.haha.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;
?>
----
Server IP: 115.182.65.88
Probable Submitter: 58.41.36.78 (proxied: 58.41.36.78)
----
Manual Page -- http://www.php.net/manual/en/function.preg-match-all.php
Edit -- https://master.php.net/note/edit/108543
Del: integrated -- https://master.php.net/note/delete/108543/integrated
Del: useless -- https://master.php.net/note/delete/108543/useless
Del: bad code -- https://master.php.net/note/delete/108543/bad+code
Del: spam -- https://master.php.net/note/delete/108543/spam
Del: non-english -- https://master.php.net/note/delete/108543/non-english
Del: in docs -- https://master.php.net/note/delete/108543/in+docs
Del: other reasons-- https://master.php.net/note/delete/108543
Reject -- https://master.php.net/note/reject/108543
Search -- https://master.php.net/manage/user-notes.php