- parse_url: documentation ( source)
- in_array: documentation ( source)
<?php
$url = 'http://mydomain.com/u/123-test';
$url = parse_url($url, PHP_URL_HOST); //$url is POST from input field
$domain = array('mydomain.com', 'mydomain.net');
if (!in_array($url, $domain)) {
echo 'invalid URL';
}else{
echo 'valid URL';
}
?>