Horje
How to count domain length in PHP | PHP Domain Code
How to count domain length in PHP

Output is correct. when input is http://test.google.co.uk value of parse_url('http://test.google.co.uk')['host'] is http://test.google.co.uk. When you will exploce this string on dot first element of array will be test and its length is 4.

To get google instead of test you need to replace subdomain with nothing as you did in your first example or take the second element in exploded string. E.g:


How to extract Domain length in PHP

Start your code here.
index.php
Example: HTML
<?php
$url    = 'http://test.google.co.uk';    
$info   = parse_url($url);    
$pieces = explode(".", $info['host']); 
$len    = strlen($pieces[1]); // returns character length of google = 6
echo $len;
?>



Read Full::
PHP Domain Code
Category:
PHP Tutorial Code
Sub Category:
PHP Domain Code
Uploaded:
2 weeks ago
Uploaded by:
Admin
Views:
6

Related Articles
How to count domain length in PHP PHP Domain Code
How to get domain extension from php string PHP Domain Code

Single Articles
How to extract Domain length in PHP

Share on: