Use regular expression to parse the document. You can find tons of examples/classes which can do this for you. www.phpclasses.org have many php classes available for this purpose.
use preg_match function in php to put them in an array preg_match("/^(http:\/\/)?([^\/]+)/i", $source, $urls); //not sure if this is the right code