Re: Getting domain out of a URL
| From: | Roman Neuhauser | Date: | Thu, 18 Jan 2007 00:10:32 +0000 |
| Subject: | Re: Getting domain out of a URL | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247273@lists.php.net to get a copy of this message | ||
# aajdubuc@webhart.net / 2007-01-17 17:53:09 -0500:
> On Wednesday 17 January 2007 03:35 pm, Jay Blanchard wrote:
> > [snip]
> > I receive posts from an open moderated forum that need to be filtered
> > for urls. I've successfully managed to trap any entires that use
> > 'http://' 'www.' with the standard
> > '.com' '.org', '.net' endings.
> >
> > What I need to do is to strip the prefix part
> > ('http:// or http://www.
> > or 'www') and suffix as well (the .com, etc.) I need only the domain
> > name. I can't seem to trim away the suffix part.
> > [/snip]
> >
> > Have you looked at
> > http://us3.php.net/manual/en/function.parse-url.php
>
> Thanks Jay for the function reference, but it doesn't seem like it's what I'm
> after since the url is packed into the text.
>
> What i really need is something that will take the first part of an array
> cutting the remainder after a delimiter word '.com'.
>
> Something along the lines of:
>
> <?php
>
> $boom[1] = "ranchy.stuff.com and other junk";
>
> $input = $boom[1];
> $out = array_slice($input, 0, 1);
>
> ?>
>
> Part of my problem, I'm beginning to realize, is that the array '$boom[1]'
> contains only one element. Is there a similar string function I could use
> that would accomplish what I need?
If there isn't one you can always compose it from the ones already available.
That's programming.
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991