3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php $uri = 'administrator/clients/client/11'; // function input $routes = array( 'administrator/clients' => 'administrator/clients', 'administrator/client/(:num)' => 'administrator/clients/client/$1', ); foreach ($routes as $route => $controller) { $key = preg_replace('#[$][0-9]+#', '([^/]+)', $controller); // Converter alle $1, $2 osv til "hvad som helts") if (preg_match('#^' . $key . '$#', $uri, $match)) { // Okay. Den matcher på $controller (array value) // Nu skal vi så konvertere $uri til den $route, der tilhører $controller $route; // Det er en her route // $uri skal altså ligne "administrator/client/11" } }
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.30
Parse error: syntax error, unexpected '<' in /in/sf2tc on line 3
Process exited with code 255.

preferences:
171.54 ms | 1395 KiB | 67 Q