3v4l.org

run code in 500+ 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 = 69
Branch analysis from position: 69
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 16
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 33
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 44) Position 1 = 71, Position 2 = 16
Branch analysis from position: 71
Branch analysis from position: 16
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 40
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 47
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 64
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 67
Branch analysis from position: 66
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MhiVJ
function name:  alphabetize_custom
number of ops:  73
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                                                   'mb_strlen'
          5        SEND_VAR                                                     !0
          6        SEND_VAR                                                     !3
          7        DO_ICALL                                             $10     
          8        INIT_FCALL                                                   'mb_strlen'
          9        SEND_VAR                                                     !1
         10        SEND_VAR                                                     !3
         11        DO_ICALL                                             $11     
         12        FRAMELESS_ICALL_2                max                 ~12     $10, $11
         13        ASSIGN                                                       !4, ~12
    5    14        ASSIGN                                                       !5, 0
         15      > JMP                                                          ->69
    7    16    >   INIT_FCALL                                                   'mb_substr'
         17        SEND_VAR                                                     !0
         18        SEND_VAR                                                     !5
         19        SEND_VAL                                                     1
         20        SEND_VAR                                                     !3
         21        DO_ICALL                                             $15     
         22        ASSIGN                                                       !6, $15
    8    23        INIT_FCALL                                                   'mb_substr'
         24        SEND_VAR                                                     !1
         25        SEND_VAR                                                     !5
         26        SEND_VAL                                                     1
         27        SEND_VAR                                                     !3
         28        DO_ICALL                                             $17     
         29        ASSIGN                                                       !7, $17
   11    30        IS_IDENTICAL                                                 !6, !7
         31      > JMPZ                                                         ~19, ->33
         32    > > JMP                                                          ->68
   12    33    >   INIT_FCALL                                                   'mb_strlen'
         34        SEND_VAR                                                     !6
         35        SEND_VAR                                                     !3
         36        DO_ICALL                                             $20     
         37        BOOL_NOT                                             ~21     $20
         38      > JMPZ                                                         ~21, ->40
         39    > > RETURN                                                       -1
   13    40    >   INIT_FCALL                                                   'mb_strlen'
         41        SEND_VAR                                                     !7
         42        SEND_VAR                                                     !3
         43        DO_ICALL                                             $22     
         44        BOOL_NOT                                             ~23     $22
         45      > JMPZ                                                         ~23, ->47
         46    > > RETURN                                                       1
   14    47    >   INIT_FCALL                                                   'mb_strpos'
         48        SEND_VAR                                                     !2
         49        SEND_VAR                                                     !6
         50        SEND_VAL                                                     0
         51        SEND_VAR                                                     !3
         52        DO_ICALL                                             $24     
         53        ASSIGN                                                       !8, $24
   15    54        INIT_FCALL                                                   'mb_strpos'
         55        SEND_VAR                                                     !2
         56        SEND_VAR                                                     !7
         57        SEND_VAL                                                     0
         58        SEND_VAR                                                     !3
         59        DO_ICALL                                             $26     
         60        ASSIGN                                                       !9, $26
   17    61        IS_EQUAL                                                     !8, !9
         62      > JMPZ                                                         ~28, ->64
         63    > > JMP                                                          ->68
   18    64    >   IS_SMALLER                                                   !8, !9
         65      > JMPZ                                                         ~29, ->67
         66    > > RETURN                                                       -1
   20    67    > > RETURN                                                       1
    5    68    >   PRE_INC                                                      !5
         69    >   IS_SMALLER                                                   !5, !4
         70      > JMPNZ                                                        ~31, ->16
   23    71    > > RETURN                                                       0
   24    72*     > RETURN                                                       null

End of function alphabetize_custom

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
225.49 ms | 2383 KiB | 18 Q