- preg_match: documentation ( source)
- implode: documentation ( source)
<?php
$paths = [
'/cars$',
'.*\/cars$',
'^cars\/.*/',
'/trucks$',
'.*\/trucks$',
];
$paths_string = '#' . implode('|', $paths) . '#';
$current_path = 'cars/honda/';
if (preg_match($paths_string, $current_path)) {
echo "it's a match!";
}