3v4l.org

run code in 500+ 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);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3XYNG
function name:  (null)
number of ops:  9
compiled vars:  !0 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                       !0, <array>
   32     1        INIT_FCALL                                                   'uksort'
          2        SEND_REF                                                     !0
          3        SEND_VAL                                                     'alphabetize_custom'
          4        DO_ICALL                                                     
   34     5        INIT_FCALL                                                   'var_export'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                                     
          8      > RETURN                                                       1

Function alphabetize_custom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 17
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 34
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 17
Branch analysis from position: 52
Branch analysis from position: 17
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 47
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 49
Branch analysis from position: 49
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3XYNG
function name:  alphabetize_custom
number of ops:  54
compiled vars:  !0 = $a, !1 = $b, !2 = $alphabet, !3 = $encoding, !4 = $mb_length, !5 = $i, !6 = $a_char, !7 = $b_char, !8 = $a_key, !9 = $b_key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    3     2        ASSIGN                                                       !2, <array>
    4     3        UNSET_DIM                                                    !2, 0
    5     4        ASSIGN                                                       !3, 'UTF-8'
    7     5        INIT_FCALL                                                   'mb_strlen'
          6        SEND_VAR                                                     !0
          7        SEND_VAR                                                     !3
          8        DO_ICALL                                             $12     
          9        INIT_FCALL                                                   'mb_strlen'
         10        SEND_VAR                                                     !1
         11        SEND_VAR                                                     !3
         12        DO_ICALL                                             $13     
         13        FRAMELESS_ICALL_2                max                 ~14     $12, $13
         14        ASSIGN                                                       !4, ~14
    8    15        ASSIGN                                                       !5, 0
         16      > JMP                                                          ->50
    9    17    >   INIT_FCALL                                                   'mb_substr'
         18        SEND_VAR                                                     !0
         19        SEND_VAR                                                     !5
         20        SEND_VAL                                                     1
         21        SEND_VAR                                                     !3
         22        DO_ICALL                                             $17     
         23        ASSIGN                                                       !6, $17
   10    24        INIT_FCALL                                                   'mb_substr'
         25        SEND_VAR                                                     !1
         26        SEND_VAR                                                     !5
         27        SEND_VAL                                                     1
         28        SEND_VAR                                                     !3
         29        DO_ICALL                                             $19     
         30        ASSIGN                                                       !7, $19
   11    31        IS_IDENTICAL                                                 !6, !7
         32      > JMPZ                                                         ~21, ->34
         33    > > JMP                                                          ->49
   13    34    >   INIT_FCALL                                                   'array_search'
         35        SEND_VAR                                                     !6
         36        SEND_VAR                                                     !2
         37        DO_ICALL                                             $22     
         38        ASSIGN                                                       !8, $22
   14    39        INIT_FCALL                                                   'array_search'
         40        SEND_VAR                                                     !7
         41        SEND_VAR                                                     !2
         42        DO_ICALL                                             $24     
         43        ASSIGN                                                       !9, $24
   15    44        IS_IDENTICAL                                                 !8, !9
         45      > JMPZ                                                         ~26, ->47
         46    > > JMP                                                          ->49
   17    47    >   SUB                                                  ~27     !8, !9
         48      > RETURN                                                       ~27
    8    49    >   PRE_INC                                                      !5
         50    >   IS_SMALLER                                                   !5, !4
         51      > JMPNZ                                                        ~29, ->17
   19    52    > > RETURN                                                       0
   20    53*     > RETURN                                                       null

End of function alphabetize_custom

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
226.09 ms | 2226 KiB | 18 Q