Horje
How to extract name only from a domain

Here I set php function where any domain or url will extract only Name. 


Extract only name from a domain or url

See the example.
index.php
Example: PHP
<?php
// Edited by Md. Rakib Khan
// support https://horje.com
function domain_name_only($var)
{ $var=str_replace('https://','',$var); $var=str_replace('http://','',$var); $vars= 'qr'.$var.''; $vars=preg_match('~qr(.*?)/~si', $vars, $tag1); $vars= $tag1[1]; if (!empty($vars)) { $var = $vars; } preg_match("/([^\.\/]+)\.[a-z\.]{2,6}$/i", $var, $match); $var = $match[1];
return $var;
}
// fucntion apply
$url = 'https://horje.com';
echo domain_name_only($url);
echo '</br>';
$url = 'https://horje.com/learn/1437/html-onplaying-event-attributes';
echo domain_name_only($url);
echo '</br>';
$url = 'horje.com';
echo domain_name_only($url);
echo '</br>';
$url = 'horje.com/learn/1437/html-onplaying-event-attributes';
echo domain_name_only($url);
echo '</br>';
?>

Output should be:





php domain

Type :
Develop
Category :
Web Tutorial
Sub Category :
PHP Function Tutorial
Uploaded by :
Admin