Wondering how I would detect a URL in a string and return a link. Example
$text = 'Go to www.example.com example.com example.net http://example.com'; echo $text;
would return
Go to www.example.com example.com etc.
Wondering how I would detect a URL in a string and return a link. Example
$text = 'Go to www.example.com example.com example.net http://example.com'; echo $text;
would return
Go to www.example.com example.com etc.
This is how I would do it.
It will echo http://google.com from
www.website.com and example.com BUT http://google.com and now www.website.com
<?php $x = "www.website.com and example.com and even http://google.com and now www.website.com I could go on forever"; $start = strpos($x, 'http://'); for($i=$start; $i < strlen($x); $i++){ if(strpos($x, '.com') == true) { $str = strpos($x, '.com'); echo $x[$i]; if($x[$i] === ' '){ break; } } }