3v4l.org

run code in 300+ PHP versions simultaneously
<?php function alphabetize_custom($a, $b, $alphabet = " -,.ȝjʿwbpfmnrhḥḫẖsšqkgtṯdḏ⸗/()[]<>{}'*#I0123456789&@%", $encoding = 'UTF-8') { //echo "\n----\n$a =vs= $b"; $mb_length = max(mb_strlen($a, $encoding), mb_strlen($b, $encoding)); for ($i = 0; $i < $mb_length; ++$i) { //echo "\n"; $a_char = mb_substr($a, $i, 1, $encoding); $b_char = mb_substr($b, $i, 1, $encoding); //echo "$a_char -vs- $b_char\n"; //echo "(" , mb_strlen($a_char, $encoding), " & ", mb_strlen($b_char, $encoding), ")\n"; if ($a_char === $b_char) {/*echo "identical, continue";*/ continue;} if (!mb_strlen($a_char, $encoding)) { /* echo "a is empty -1";*/ return -1;} if (!mb_strlen($b_char, $encoding)) { /*echo "b is empty 1";*/ return 1;} $a_offset = mb_strpos($alphabet, $a_char, 0, $encoding); $b_offset = mb_strpos($alphabet, $b_char, 0, $encoding); //echo "[" , $a_offset, " & ", $b_offset, "]\n"; if ($a_offset == $b_offset) { /*echo "== offsets, continue";*/ continue;} if ($a_offset < $b_offset) { /*echo "a offset -1";*/ return -1;} //echo "b offset 1"; return 1; } //echo "0"; 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/MhiVJ
function name:  (null)
number of ops:  9
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   ASSIGN                                                   !0, <array>
   36     1        INIT_FCALL                                               'uksort'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'alphabetize_custom'
          4        DO_ICALL                                                 
   38     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 = 72
Branch analysis from position: 72
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 19
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 36
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 74, Position 2 = 19
Branch analysis from position: 74
Branch analysis from position: 19
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 43
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 50
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 67
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 70
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 70
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MhiVJ
function name:  alphabetize_custom
number of ops:  76
compiled vars:  !0 = $a, !1 = $b, !2 = $alphabet, !3 = $encoding, !4 = $mb_length, !5 = $i, !6 = $a_char, !7 = $b_char, !8 = $a_offset, !9 = $b_offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      '+-%2C.%C8%9Dj%CA%BFwbpfmnrh%E1%B8%A5%E1%B8%AB%E1%BA%96s%C5%A1qkgt%E1%B9%AFd%E1%B8%8F%E2%B8%97%2F%28%29%5B%5D%3C%3E%7B%7D%27%2A%23I0123456789%26%40%25'
          3        RECV_INIT                                        !3      'UTF-8'
    4     4        INIT_FCALL                                               'max'
          5        INIT_FCALL                                               'mb_strlen'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !3
          8        DO_ICALL                                         $10     
          9        SEND_VAR                                                 $10
         10        INIT_FCALL                                               'mb_strlen'
         11        SEND_VAR                                                 !1
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $11     
         14        SEND_VAR                                                 $11
         15        DO_ICALL                                         $12     
         16        ASSIGN                                                   !4, $12
    5    17        ASSIGN                                                   !5, 0
         18      > JMP                                                      ->72
    7    19    >   INIT_FCALL                                               'mb_substr'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !5
         22        SEND_VAL                                                 1
         23        SEND_VAR                                                 !3
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !6, $15
    8    26        INIT_FCALL                                               'mb_substr'
         27        SEND_VAR                                                 !1
         28        SEND_VAR                                                 !5
         29        SEND_VAL                                                 1
         30        SEND_VAR                                                 !3
         31        DO_ICALL                                         $17     
         32        ASSIGN                                                   !7, $17
   11    33        IS_IDENTICAL                                             !6, !7
         34      > JMPZ                                                     ~19, ->36
         35    > > JMP                                                      ->71
   12    36    >   INIT_FCALL                                               'mb_strlen'
         37        SEND_VAR                                                 !6
         38        SEND_VAR                                                 !3
         39        DO_ICALL                                         $20     
         40        BOOL_NOT                                         ~21     $20
         41      > JMPZ                                                     ~21, ->43
         42    > > RETURN                                                   -1
   13    43    >   INIT_FCALL                                               'mb_strlen'
         44        SEND_VAR                                                 !7
         45        SEND_VAR                                                 !3
         46        DO_ICALL                                         $22     
         47        BOOL_NOT                                         ~23     $22
         48      > JMPZ                                                     ~23, ->50
         49    > > RETURN                                                   1
   14    50    >   INIT_FCALL                                               'mb_strpos'
         51        SEND_VAR                                                 !2
         52        SEND_VAR                                                 !6
         53        SEND_VAL                                                 0
         54        SEND_VAR                                                 !3
         55        DO_ICALL                                         $24     
         56        ASSIGN                                                   !8, $24
   15    57        INIT_FCALL                                               'mb_strpos'
         58        SEND_VAR                                                 !2
         59        SEND_VAR                                                 !7
         60        SEND_VAL                                                 0
         61        SEND_VAR                                                 !3
         62        DO_ICALL                                         $26     
         63        ASSIGN                                                   !9, $26
   17    64        IS_EQUAL                                                 !8, !9
         65      > JMPZ                                                     ~28, ->67
         66    > > JMP                                                      ->71
   18    67    >   IS_SMALLER                                               !8, !9
         68      > JMPZ                                                     ~29, ->70
         69    > > RETURN                                                   -1
   20    70    > > RETURN                                                   1
    5    71    >   PRE_INC                                                  !5
         72    >   IS_SMALLER                                               !5, !4
         73      > JMPNZ                                                    ~31, ->19
   23    74    > > RETURN                                                   0
   24    75*     > RETURN                                                   null

End of function alphabetize_custom

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.89 ms | 1404 KiB | 25 Q