3v4l.org

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

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.07320.23
7.0.10.0070.06320.25
7.0.00.0070.08320.25
5.6.170.0230.04320.58
5.6.160.0030.07320.52
5.6.150.0070.08318.22
5.6.140.0100.03318.18
5.6.130.0030.05718.15
5.6.120.0100.06321.00
5.6.110.0100.06721.00
5.6.100.0130.08021.00
5.6.90.0200.07721.00
5.6.80.0030.04020.50
5.5.310.0230.05020.19
5.5.300.0000.04717.99
5.5.290.0030.05017.94
5.5.280.0100.04020.96
5.5.270.0170.07320.82
5.5.260.0070.07320.76
5.5.250.0030.08720.79
5.5.240.0230.07320.23

preferences:
141.37 ms | 1394 KiB | 7 Q