@ 2016-01-19T13:32:44Z <?php
// CHANGE THIS
$url = '/12345/product';
$routes = [
'primary' => [
'pattern' => '#/(?P<resource>[^/\\\\.,;?\n]+)/foobar#',
'default' => [
'action' => 'standard',
],
],
'secundary' => [
'pattern' => '#^/(?P<id>[0-9]+)(?:/(?P<resource>[^/\\\\.,;?\n]+)(?:/(?P<action>[^/\\\\.,;?\n]+))?)?$#',
'default' => [
'resource' => 'catalog',
'action' => 'view',
]
],
'fallback' => [
'pattern' => '#^.*$#',
'default' => [
'resource' => 'main',
'action' => 'landing',
],
],
];
$current = null;
// matching the route
foreach ($routes as $name => $route) {
echo "$name\t\t";
$matches = [];
if ( preg_match( $route['pattern'], $url, $matches ) ) {
$current = $name;
$matches = $matches + $route['default'];
break;
}
}
// cleaning up results
foreach ( array_keys($matches) as $key ) {
if ( is_numeric($key) ) {
unset( $matches[$key] );
}
}
// view results
echo "\n";
var_dump( $current, [4,6]]+[1,2] );
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.0.2 0.027 0.050 20.07 7.0.1 0.017 0.050 20.05 7.0.0 0.007 0.080 20.20 5.6.17 0.030 0.043 20.62 5.6.16 0.010 0.043 20.71 5.6.15 0.003 0.043 18.27 5.6.14 0.007 0.070 18.14 5.6.13 0.007 0.043 18.20 5.6.12 0.013 0.040 21.02 5.6.11 0.020 0.057 20.96 5.6.10 0.010 0.083 21.01 5.6.9 0.007 0.087 20.98 5.6.8 0.003 0.037 20.53 5.5.31 0.020 0.037 20.41 5.5.30 0.003 0.067 17.96 5.5.29 0.010 0.057 17.91 5.5.28 0.013 0.060 20.96 5.5.27 0.010 0.067 20.65 5.5.26 0.010 0.083 20.64 5.5.25 0.013 0.073 20.69 5.5.24 0.030 0.063 20.23
preferences:dark mode live preview
140.16 ms | 1394 KiB | 7 Q