3v4l.org

run code in 300+ PHP versions simultaneously
<?php const UNIT_FACTOR = [ 'B' => 1, 'KB' => 1024, 'MB' => 1048576, 'GB' => 1073741824, ]; $array = [ 0 => "100 MB", 4 => "10 MB", 8 => "1GB", 12 => "20 MB", 16 => "250 MB", 20 => "2GB", 24 => "4 MB", 28 => "500 MB", 32 => "50 MB", 36 => "5GB", 40 => "8GB", 44 => "0 MB" ]; $bytes = []; foreach ($array as $string) { sscanf($string, '%f%s', $amount, $unit); $bytes[] = $amount * UNIT_FACTOR[$unit]; } array_multisort($bytes, $array); var_export($array);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => '0 MB', 1 => '4 MB', 2 => '10 MB', 3 => '20 MB', 4 => '50 MB', 5 => '100 MB', 6 => '250 MB', 7 => '500 MB', 8 => '1GB', 9 => '2GB', 10 => '5GB', 11 => '8GB', )

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:
66.8 ms | 405 KiB | 5 Q