3v4l.org

run code in 300+ PHP versions simultaneously
<?php function alphabetize_custom($a, $b) { $alphabet = [' ', '-', ',', '.', 'ȝ', 'j', 'ʿ', 'w', 'b', 'p', 'f', 'm', 'n', 'r', 'h', 'ḥ', 'ḫ', 'ẖ', 's', 'š', 'q', 'k', 'g', 't', 'ṯ', 'd', 'ḏ', '⸗', '/', '(', ')', '[', ']', '<', '>', '{', '}', "'", '*', '#', 'I', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '&', '@', '%']; unset($alphabet[0]); // removes dummy first key, effectively starting the keys from 1 $encoding = 'UTF-8'; $mb_length = max(mb_strlen($a, $encoding), mb_strlen($b, $encoding)); for ($i = 0; $i < $mb_length; ++$i) { $a_char = mb_substr($a, $i, 1, $encoding); $b_char = mb_substr($b, $i, 1, $encoding); if ($a_char === $b_char) continue; $a_key = array_search($a_char, $alphabet); $b_key = array_search($b_char, $alphabet); if ($a_key === $b_key) continue; return $a_key - $b_key; } return 0; } $result = [ "nṯr" => ["Ka.C.Coptite.urkVIII,176b", "Ka.C.Coptite.urkVIII,177,1"], "n" => ["Ka.C.Coptite.urkVIII,176c", "Ka.C.Coptite.urkVIII,177,1", "Ka.C.Coptite.urkVIII,177,2"], "nḫȝḫȝ" => ["Ka.C.Coptite.urkVIII,176c"], "nwj" => ["Ka.C.Coptite.urkVIII,176c"], "nfr" => ["Ka.C.Coptite.urkVIII,176c", "Ka.C.Coptite.urkVIII,177,2"], "nḥḥ" => ["Ka.C.Coptite.urkVIII,176e", "Ka.C.Coptite.urkVIII,177,1", "Ka.C.Coptite.urkVIII,177,1"], "nḏ" => ["Ka.C.Coptite.urkVIII,177,1"] ]; uksort($result, 'alphabetize_custom'); var_export($result);
Output for git.master, git.master_jit, rfc.property-hooks
array ( 'n' => array ( 0 => 'Ka.C.Coptite.urkVIII,176c', 1 => 'Ka.C.Coptite.urkVIII,177,1', 2 => 'Ka.C.Coptite.urkVIII,177,2', ), 'nwj' => array ( 0 => 'Ka.C.Coptite.urkVIII,176c', ), 'nfr' => array ( 0 => 'Ka.C.Coptite.urkVIII,176c', 1 => 'Ka.C.Coptite.urkVIII,177,2', ), 'nḥḥ' => array ( 0 => 'Ka.C.Coptite.urkVIII,176e', 1 => 'Ka.C.Coptite.urkVIII,177,1', 2 => 'Ka.C.Coptite.urkVIII,177,1', ), 'nḫȝḫȝ' => array ( 0 => 'Ka.C.Coptite.urkVIII,176c', ), 'nṯr' => array ( 0 => 'Ka.C.Coptite.urkVIII,176b', 1 => 'Ka.C.Coptite.urkVIII,177,1', ), 'nḏ' => array ( 0 => 'Ka.C.Coptite.urkVIII,177,1', ), )

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:
54.43 ms | 402 KiB | 8 Q