3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ '2DAYSALEGATE_PG1.jpg', '2DAYSALEGATE_PG2.jpg', '722_PG1.jpg', 'PW_PG2_COKE_A.jpg', 'PW_PG3_COKE_A.jpg', 'PWBY4_DELI-1.jpg' ]; function sortArrayOfStrings($array): array { array_multisort( str_replace('_', ' ', $array), SORT_NATURAL, $array ); return $array; } function dimaSort($array): array { usort($array, function ($a, $b) { $aTemp = str_replace('_', '0', $a); $bTemp = str_replace('_', '0', $b); return strcmp($aTemp,$bTemp); }); return $array; } var_export([ sortArrayOfStrings($array), dimaSort($array) ]);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 0 => '2DAYSALEGATE_PG1.jpg', 1 => '2DAYSALEGATE_PG2.jpg', 2 => '722_PG1.jpg', 3 => 'PWBY4_DELI-1.jpg', 4 => 'PW_PG2_COKE_A.jpg', 5 => 'PW_PG3_COKE_A.jpg', ), 1 => array ( 0 => '2DAYSALEGATE_PG1.jpg', 1 => '2DAYSALEGATE_PG2.jpg', 2 => '722_PG1.jpg', 3 => 'PW_PG2_COKE_A.jpg', 4 => 'PW_PG3_COKE_A.jpg', 5 => 'PWBY4_DELI-1.jpg', ), )

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:
91.68 ms | 406 KiB | 5 Q