Horje
How to get domain extension from php string | PHP Domain Code
How to get domain extension from php string

Use parse_url(). Something like:


How to show Domain Extension from PHP String

Try following codes.
index.html
Example: HTML
<?php
$host = parse_url('http://www.google.co.uk/test.html');
preg_match('/(.*?)((\.co)?.[a-z]{2,4})$/i', $host['host'], $m);

$ext = isset($m[2]) ? $m[2]: '';
echo $ext; ?>



Read Full::
PHP Domain Code
Category:
PHP Tutorial Code
Sub Category:
PHP Domain Code
Uploaded:
2 weeks ago
Uploaded by:
Admin
Views:
4
Tested on:
PHP 7

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 show Domain Extension from PHP String

Share on: