3v4l.org

run code in 300+ PHP versions simultaneously
<?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] );

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).

VersionSystem time (s)User time (s)Memory (MiB)
7.0.20.0270.05020.07
7.0.10.0170.05020.05
7.0.00.0070.08020.20
5.6.170.0300.04320.62
5.6.160.0100.04320.71
5.6.150.0030.04318.27
5.6.140.0070.07018.14
5.6.130.0070.04318.20
5.6.120.0130.04021.02
5.6.110.0200.05720.96
5.6.100.0100.08321.01
5.6.90.0070.08720.98
5.6.80.0030.03720.53
5.5.310.0200.03720.41
5.5.300.0030.06717.96
5.5.290.0100.05717.91
5.5.280.0130.06020.96
5.5.270.0100.06720.65
5.5.260.0100.08320.64
5.5.250.0130.07320.69
5.5.240.0300.06320.23

preferences:
140.16 ms | 1394 KiB | 7 Q