- preg_match: documentation ( source)
- print_r: documentation ( source)
- array_filter: documentation ( source)
<?PHP
$paths = [
'/cars$',
'.*/cars$',
'^cars/.*/',
'/trucks$',
'.*/trucks$'
];
$url = 'some-site.com/cars';
$res = array_filter($paths, function ($v) USE ($url) {
return preg_match('~'.$v.'~', $url);
});
echo count($res)." patterns matched:\n";
print_r($res);
?>