You have to use regular expressions. preg and ereg are both interesting in PHP, considering that ereg is easier to use, but slower.
Here is a simple preg call that will get URLs from $text.
preg_match_all("/https?:\/\/[^\s]+/i", $text, $urls);
$urls is an array of your URLs.