php foreach routes as pattern route if preg_match ltrim pattern trim _

1
2
3
4
5
6
7
8
9
<?php
foreach ($routes as $pattern => $route) {
if (preg_match('#^' . ltrim($pattern, '/') . '$#', trim($_SERVER['REQUEST_URI'], '/'), $matches)) {
$controller = $route;
$_GET = array_merge($_GET, clear_numberic_matches($matches));
break;
}
}
?>