3v4l.org

run code in 300+ PHP versions simultaneously
<?php $abc = array( 'rec_1' => array('fn'=>'Aron','ln'=>'Michaels'), 'rec_2' => array('fn'=>'Abbey','ln'=>'Drake'), 'rec_3' => array('fn'=>'Alice','ln'=>'Peterson')); /*function build_sorter($key) { return function ($a, $b) use ($key) { return strcmp($a[$key], $b[$key]); }; }*/ function sortit($a, $b , $key) { return strcmp($a[$key], $b[$key]); }; function mysort($key) { return sortit($a,$b,$key); } //usort($abc, build_sorter('ln')); usort($abc, mysort('ln')); foreach ($abc as $item) { echo strtoupper($item['ln']) . ', ' . $item['fn'] . "\n"; }
Output for git.master, git.master_jit
Warning: Undefined variable $a in /in/tDvVM on line 20 Warning: Undefined variable $b in /in/tDvVM on line 20 Warning: Trying to access array offset on value of type null in /in/tDvVM on line 15 Warning: Trying to access array offset on value of type null in /in/tDvVM on line 15 Deprecated: strcmp(): Passing null to parameter #1 ($string1) of type string is deprecated in /in/tDvVM on line 15 Deprecated: strcmp(): Passing null to parameter #2 ($string2) of type string is deprecated in /in/tDvVM on line 15 Fatal error: Uncaught TypeError: usort(): Argument #2 ($callback) must be a valid callback, no array or string given in /in/tDvVM:27 Stack trace: #0 /in/tDvVM(27): usort(Array, 0) #1 {main} thrown in /in/tDvVM on line 27
Process exited with code 255.
Output for rfc.property-hooks
Warning: Undefined variable $a in /in/tDvVM on line 20 Warning: Undefined variable $b in /in/tDvVM on line 20 Warning: Trying to access array offset on null in /in/tDvVM on line 15 Warning: Trying to access array offset on null in /in/tDvVM on line 15 Deprecated: strcmp(): Passing null to parameter #1 ($string1) of type string is deprecated in /in/tDvVM on line 15 Deprecated: strcmp(): Passing null to parameter #2 ($string2) of type string is deprecated in /in/tDvVM on line 15 Fatal error: Uncaught TypeError: usort(): Argument #2 ($callback) must be a valid callback, no array or string given in /in/tDvVM:27 Stack trace: #0 /in/tDvVM(27): usort(Array, 0) #1 {main} thrown in /in/tDvVM on line 27
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:
50.33 ms | 401 KiB | 8 Q