3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array_0 = [ ['firstName' => 'Zoe', 'lastName' => 'Black', 'age' => 32, 'sex' => 'Female'], ['firstName' => 'Alex', 'lastName' => 'Katter', 'age' => 24, 'sex' => 'Male'], ['firstName' => 'Daniel', 'lastName' => 'Farmer', 'age' => 54, 'sex' => 'Male'], ['firstName' => 'Casy', 'lastName' => 'Denali', 'age' => 26, 'sex' => 'Female'], ['firstName' => 'Dave', 'lastName' => 'Desopolous', 'age' => 21, 'sex' => 'Male'], ['firstName' => 'Hugo', 'lastName' => 'Tesserat', 'age' => 43, 'sex' => 'Male'], ['firstName' => 'Sandy', 'lastName' => 'Williams', 'age' => 34, 'sex' => 'Female'], ['firstName' => 'Beth', 'lastName' => 'Baronksy', 'age' => 39, 'sex' => 'Female'], ['firstName' => 'David', 'lastName' => 'Faller', 'age' => 63, 'sex' => 'Male'], ['firstName' => 'Daniel', 'lastName' => 'Dekresta', 'age' => 32, 'sex' => 'Male'] ]; $orderBy_0 = function ($i) { return $i['firstName']; }; $orderBy_1 = function ($i) { return $i['lastName']; }; $t = function & () use ($array_0, $orderBy_0, $orderBy_1) { $projected_0 = []; $projected_1 = []; $elements_0 = []; $elements_0 = []; foreach($array_0 as $key_1 => &$value_1) { $keyHash_0 = \Pinq\Iterators\Common\Identity::hash($key_1); $keyMap_0[$keyHash_0] = $key_1; $projected_0[$keyHash_0] = $orderBy_0($value_1, $key_1); $projected_1[$keyHash_0] = $orderBy_1($value_1, $key_1); $elements_0[$keyHash_0] =& $value_1; unset($value_1); } foreach($elements_0 as $keyHash_0 => &$value_0) { $key_0 = $keyMap_0[$keyHash_0]; yield $key_0 => $value_0; unset($value_0); } }; var_dump(iterator_to_array($t(), true));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Class "Pinq\Iterators\Common\Identity" not found in /in/QiFdc:26 Stack trace: #0 [internal function]: {closure}() #1 /in/QiFdc(41): iterator_to_array(Object(Generator), true) #2 {main} thrown in /in/QiFdc on line 26
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught Error: Class 'Pinq\Iterators\Common\Identity' not found in /in/QiFdc:26 Stack trace: #0 [internal function]: {closure}() #1 /in/QiFdc(41): iterator_to_array(Object(Generator), true) #2 {main} thrown in /in/QiFdc on line 26
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Fatal error: Class 'Pinq\Iterators\Common\Identity' not found in /in/QiFdc on line 26
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Parse error: syntax error, unexpected '$key_0' (T_VARIABLE) in /in/QiFdc on line 35
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/QiFdc on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/QiFdc on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/QiFdc on line 4
Process exited with code 255.

preferences:
274.15 ms | 401 KiB | 359 Q