Coastal Web
08-12-2007, 02:55 AM
Greetings everyone,
I'm trying to write up a script but l've run into a road block here. After searching google for a bit l wasn't able to turn up anything that really helped me (l also searched the forum here to see if this has been asked before...)
What l'm trying to do is create a function that will go through a string, extract all the URLS form the string, and return them as an array.
For instance....
<?php
$str = <<<end
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. http://www.test.com/somefile.php Ut wisi enim ad minim veniam, quis nostrud exercitation ulliam corper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem veleum iriure dolor http://www.domain.com/files/deep/link.php?id=123&user=123 in hendrerit in vulputate velit esse molestie consequat, vel willum lunombro dolore eu feugiat nulla facilisis at vero http://www.google.com/ eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
end;
//how would l create a function that would go through a string passed to it (similar to the string above), and fetch out all of the URLS within that string (if any) and return those URLS in an array; in this case there would be three urls return within the array...
// http://www.test.com/somefile.php
// http://www.domain.com/files/deep/link.php?id=123&user=123
// http://www.google.com/
?>
If anyone would be willing to help me out with this is would be greatly appreciated.
Thanks so much,
I'm trying to write up a script but l've run into a road block here. After searching google for a bit l wasn't able to turn up anything that really helped me (l also searched the forum here to see if this has been asked before...)
What l'm trying to do is create a function that will go through a string, extract all the URLS form the string, and return them as an array.
For instance....
<?php
$str = <<<end
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. http://www.test.com/somefile.php Ut wisi enim ad minim veniam, quis nostrud exercitation ulliam corper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem veleum iriure dolor http://www.domain.com/files/deep/link.php?id=123&user=123 in hendrerit in vulputate velit esse molestie consequat, vel willum lunombro dolore eu feugiat nulla facilisis at vero http://www.google.com/ eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
end;
//how would l create a function that would go through a string passed to it (similar to the string above), and fetch out all of the URLS within that string (if any) and return those URLS in an array; in this case there would be three urls return within the array...
// http://www.test.com/somefile.php
// http://www.domain.com/files/deep/link.php?id=123&user=123
// http://www.google.com/
?>
If anyone would be willing to help me out with this is would be greatly appreciated.
Thanks so much,