3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sort_array_item_by_size($a, $b): int { static $sizes = [ "XXS" => 0, "XS" => 1, "S" => 2, "M" => 3, "L" => 4, "XL" => 5, "XXL" => 6, ]; // The next three lines really should include some error checking $size_a = explode("_", $a)[1]; $size_b = explode("_", $b)[1]; return $sizes[$size_a] <=> $sizes[$size_b]; } $your_array = ["GL001_XXL", "GL001_L", "GL001_XXS", "GL001_S"]; usort($your_array, "sort_array_item_by_size"); print_r($your_array);
Output for git.master_jit, git.master, rfc.property-hooks
Array ( [0] => GL001_XXS [1] => GL001_S [2] => GL001_L [3] => GL001_XXL )

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