3v4l.org

run code in 300+ PHP versions simultaneously
<?php $user = [ 'id' => 1, 'name' => 'Ivan Ivanov', 'role' => 'developer', 'salary' => 100 ]; $apiTemplatesSet1 = [ '/api/items/%id%/%name%', '/api/items/%id%/%role%', '/api/items/%id%/%salary%' ]; class Invoker { private $data; public function __construct(array $data) { $this->data = $data; } public function __invoke(array $key): string { return $this->data[$key[1]]; } } $function = new Invoker($user); $result = array_map(function ($key) use ($function) { return preg_replace_callback('#%(.*)%#isU', $function, $key); } , array_values($apiTemplatesSet1)); echo '<pre>' . print_r($result, true);
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [0] => /api/items/1/Ivan Ivanov [1] => /api/items/1/developer [2] => /api/items/1/100 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
57.97 ms | 401 KiB | 8 Q