@ 2016-01-15T23:49:55Z <?php
// CHANGE THIS
$url = '/12345/product/list/somevar';
$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) {
$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
var_dump( $current, $matches );
<?php
$a1=array("red","green");
$a2=array("blue","yellow");
print_r(array_merge($a1,$a2));
?>
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.073 20.23 7.0.1 0.007 0.063 20.25 7.0.0 0.007 0.083 20.25 5.6.17 0.023 0.043 20.58 5.6.16 0.003 0.073 20.52 5.6.15 0.007 0.083 18.22 5.6.14 0.010 0.033 18.18 5.6.13 0.003 0.057 18.15 5.6.12 0.010 0.063 21.00 5.6.11 0.010 0.067 21.00 5.6.10 0.013 0.080 21.00 5.6.9 0.020 0.077 21.00 5.6.8 0.003 0.040 20.50 5.5.31 0.023 0.050 20.19 5.5.30 0.000 0.047 17.99 5.5.29 0.003 0.050 17.94 5.5.28 0.010 0.040 20.96 5.5.27 0.017 0.073 20.82 5.5.26 0.007 0.073 20.76 5.5.25 0.003 0.087 20.79 5.5.24 0.023 0.073 20.23
preferences:dark mode live preview
141.37 ms | 1394 KiB | 7 Q