3v4l.org

run code in 300+ PHP versions simultaneously
<?php function remap($e) { $elements = array( 1 => 'first_name', 2 => 'city', 3 => 'email', 4 => 'phone' ); $key = isset($elements[$e['element_id']]) ? $elements[$e['element_id']]: 'unknown'; return array($key => $e['value']); } $input[] = array('entry_id' => 33, 'element_id' => 1, 'value' => 'Fred'); $input[] = array('entry_id' => 33, 'element_id' => 2, 'value' => 'Phoenix'); $input[] = array('entry_id' => 33, 'element_id' => 3, 'value' => 'fred@test.com'); $input[] = array('entry_id' => 33, 'element_id' => 99, 'value' => 'Something else entirely'); $output = array(); foreach(array_map('remap', $input, $elements) as $key => $value) { $output[$key] = $value; }; var_dump($output);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $elements in /in/nNIpf on line 23 Fatal error: Uncaught TypeError: array_map(): Argument #3 must be of type array, null given in /in/nNIpf:23 Stack trace: #0 /in/nNIpf(23): array_map('remap', Array, NULL) #1 {main} thrown in /in/nNIpf on line 23
Process exited with code 255.

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:
65.36 ms | 401 KiB | 8 Q