3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', ]; function multisort($array) { array_multisort(array_map('strlen', $array), SORT_DESC, $array); printf( "Total strlen() calls: %d\n%s\n---\n", count($array), var_export($array, true) ); } function usersort($array) { usort( $array, function($a, $b) { echo "strlen() called twice\n"; return strlen($b) <=> strlen($a); } ); var_export($array); echo "\n---\n"; } multisort($array); usersort($array);
Output for git.master, git.master_jit, rfc.property-hooks
Total strlen() calls: 9 array ( 0 => 'eight', 1 => 'seven', 2 => 'three', 3 => 'five', 4 => 'four', 5 => 'nine', 6 => 'one', 7 => 'six', 8 => 'two', ) --- strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice strlen() called twice array ( 0 => 'three', 1 => 'seven', 2 => 'eight', 3 => 'four', 4 => 'five', 5 => 'nine', 6 => 'one', 7 => 'two', 8 => 'six', ) ---

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:
129.67 ms | 407 KiB | 5 Q