RE: [PHP] Getting domain out of a URL
| From: | Jay Blanchard | Date: | Wed, 17 Jan 2007 23:16:43 +0000 |
| Subject: | RE: [PHP] Getting domain out of a URL | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-247275@lists.php.net to get a copy of this message | ||
[snip]
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?
[/snip]
Why not use explode with the period (.) as the delimiter?
$url = ranchy.stuff.com and other junk";
$boom = explode(".", $url);
print_r($boom);
$boom is now an array containing 'ranchy', 'stuff', 'com and other
junk'