Ver Mensaje Individual
  #6 (permalink)  
Antiguo 08/01/2011, 00:01
DiamanteZero
 
Fecha de Ingreso: enero-2011
Mensajes: 44
Antigüedad: 13 años, 3 meses
Puntos: 1
Respuesta: Se puede hacer algo asi.

maycolalvarez, creo que encontre 2 formas para hacerlo usando PHP, si tengo razon me gustaria que fueras el 1ero en darme algo de Karma.
forma1:
Código PHP:
function GetDomain($url)
{
$nowww ereg_replace('www\.','',$url);
$domain parse_url($nowww);
if(!empty(
$domain["host"]))
    {
     return 
$domain["host"];
     } else
     {
     return 
$domain["path"];
     }


forma2:
Código PHP:
<?php
// get host name from URL
preg_match("/^(http:\/\/)?([^\/]+)/i",
    
"http://www.php.net/index.html"$matches);
$host $matches[2];

// get last two segments of host name
preg_match("/[^\.\/]+\.[^\.\/]+$/"$host$matches);
echo 
"domain name is: {$matches[0]}\n";

/* Output is php.net */

?>
fuente de la informacion: http://corpocrat.com/2009/02/28/php-how-to-get-domain-hostname-from-url/