mercredi 30 mai 2018

Validate parts of URLs with PHP

I'm trying to check against an array of URL's with PHP, but one of the URL's will have some random strings in front of it (generated sub domain).

This is what I have so far:

<?php
$urls = array(
    '127.0.0.1',
    'develop.domain.com'
);
?>

<?php if (in_array($_SERVER['SERVER_NAME'], $urls)) : ?>
//do the thing
<?php endif; ?>

The only thing is that the develop.domain.com will have something in front of it. For example namething.develop.domain.com. Is there a way to check for a wildcard in the array of URL's so that it can check for the 127.0.0.1 and and matches for develop.domain.com?

Aucun commentaire:

Enregistrer un commentaire