3v4l.org

run code in 300+ PHP versions simultaneously
<?php function ordutf8($string, &$offset) { $code = ord(substr($string, $offset,1)); if ($code >= 128) { //otherwise 0xxxxxxx if ($code < 224) $bytesnumber = 2; //110xxxxx else if ($code < 240) $bytesnumber = 3; //1110xxxx else if ($code < 248) $bytesnumber = 4; //11110xxx $codetemp = $code - 192 - ($bytesnumber > 2 ? 32 : 0) - ($bytesnumber > 3 ? 16 : 0); for ($i = 2; $i <= $bytesnumber; $i++) { $offset ++; $code2 = ord(substr($string, $offset, 1)) - 128; //10xxxxxx $codetemp = $codetemp*64 + $code2; } $code = $codetemp; } $offset += 1; if ($offset >= strlen($string)) $offset = -1; return $code; } $text = "abcàê߀abc"; $offset = 0; while ($offset >= 0) { echo $offset.": ".ordutf8($text, $offset)."\n"; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 3
Branch analysis from position: 13
Branch analysis from position: 3
filename:       /in/BVU3q
function name:  (null)
number of ops:  14
compiled vars:  !0 = $text, !1 = $offset
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                   !0, 'abc%C3%A0%C3%AA%C3%9F%E2%82%ACabc'
   22     1        ASSIGN                                                   !1, 0
   23     2      > JMP                                                      ->11
   24     3    >   CONCAT                                           ~4      !1, '%3A+'
          4        INIT_FCALL                                               'ordutf8'
          5        SEND_VAR                                                 !0
          6        SEND_REF                                                 !1
          7        DO_FCALL                                      0  $5      
          8        CONCAT                                           ~6      ~4, $5
          9        CONCAT                                           ~7      ~6, '%0A'
         10        ECHO                                                     ~7
   23    11    >   IS_SMALLER_OR_EQUAL                                      0, !1
         12      > JMPNZ                                                    ~8, ->3
   27    13    > > RETURN                                                   1

Function ordutf8:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 58
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 36
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 40
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 63
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 40
Branch analysis from position: 57
Branch analysis from position: 40
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
Branch analysis from position: 35
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
Branch analysis from position: 29
Branch analysis from position: 24
Branch analysis from position: 58
filename:       /in/BVU3q
function name:  ordutf8
number of ops:  65
compiled vars:  !0 = $string, !1 = $offset, !2 = $code, !3 = $bytesnumber, !4 = $codetemp, !5 = $i, !6 = $code2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        INIT_FCALL                                               'ord'
          3        INIT_FCALL                                               'substr'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 1
          7        DO_ICALL                                         $7      
          8        SEND_VAR                                                 $7
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !2, $8
    4    11        IS_SMALLER_OR_EQUAL                                      128, !2
         12      > JMPZ                                                     ~10, ->58
    5    13    >   IS_SMALLER                                               !2, 224
         14      > JMPZ                                                     ~11, ->17
         15    >   ASSIGN                                                   !3, 2
         16      > JMP                                                      ->24
    6    17    >   IS_SMALLER                                               !2, 240
         18      > JMPZ                                                     ~13, ->21
         19    >   ASSIGN                                                   !3, 3
         20      > JMP                                                      ->24
    7    21    >   IS_SMALLER                                               !2, 248
         22      > JMPZ                                                     ~15, ->24
         23    >   ASSIGN                                                   !3, 4
    8    24    >   SUB                                              ~17     !2, 192
         25        IS_SMALLER                                               2, !3
         26      > JMPZ                                                     ~18, ->29
         27    >   QM_ASSIGN                                        ~19     32
         28      > JMP                                                      ->30
         29    >   QM_ASSIGN                                        ~19     0
         30    >   SUB                                              ~20     ~17, ~19
         31        IS_SMALLER                                               3, !3
         32      > JMPZ                                                     ~21, ->35
         33    >   QM_ASSIGN                                        ~22     16
         34      > JMP                                                      ->36
         35    >   QM_ASSIGN                                        ~22     0
         36    >   SUB                                              ~23     ~20, ~22
         37        ASSIGN                                                   !4, ~23
    9    38        ASSIGN                                                   !5, 2
         39      > JMP                                                      ->55
   10    40    >   PRE_INC                                                  !1
   11    41        INIT_FCALL                                               'ord'
         42        INIT_FCALL                                               'substr'
         43        SEND_VAR                                                 !0
         44        SEND_VAR                                                 !1
         45        SEND_VAL                                                 1
         46        DO_ICALL                                         $27     
         47        SEND_VAR                                                 $27
         48        DO_ICALL                                         $28     
         49        SUB                                              ~29     $28, 128
         50        ASSIGN                                                   !6, ~29
   12    51        MUL                                              ~31     !4, 64
         52        ADD                                              ~32     ~31, !6
         53        ASSIGN                                                   !4, ~32
    9    54        PRE_INC                                                  !5
         55    >   IS_SMALLER_OR_EQUAL                                      !5, !3
         56      > JMPNZ                                                    ~35, ->40
   14    57    >   ASSIGN                                                   !2, !4
   16    58    >   ASSIGN_OP                                     1          !1, 1
   17    59        STRLEN                                           ~38     !0
         60        IS_SMALLER_OR_EQUAL                                      ~38, !1
         61      > JMPZ                                                     ~39, ->63
         62    >   ASSIGN                                                   !1, -1
   18    63    > > RETURN                                                   !2
   19    64*     > RETURN                                                   null

End of function ordutf8

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.25 ms | 1407 KiB | 18 Q