1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
<?php
function xtoto($url) {
$site = parse_url($url, PHP_URL_HOST);
$domaine = array_reverse(explode('.',$site))[1];
$pattern = "/[a-z]{4}[A-Z]{4}/";
return preg_match($pattern, $domaine);
}
// en mode incompréhensible
function toto($url) {
return preg_match("/[a-z]{4}[A-Z]{4}/", array_reverse(explode('.',parse_url($url, PHP_URL_HOST)))[1]);
}
var_dump(toto('http://www.abcdeABCDE.com'));
print "<br/>";
var_dump(toto('http://www.abcde.com/ABCDEF/'));
print "<br/>";
var_dump(toto('http://www.abcde.com/'));
print "<br/>";
var_dump(toto('http://www.abcde.com'));
print "<br/>";
var_dump(toto('http://www.abcdeABCDE.com/abcedf'));
print "<br/>";
?> |
Partager