3v4l.org

run code in 300+ PHP versions simultaneously
<?php function tag($str,$pos1,$pos2) { $offset=-1; $arrs=explode("-",$str); list($pos1,$pos2)=array(min($pos1,$pos2),max($pos1,$pos2)); foreach($arrs as &$chunk) { $len=strlen($chunk); if($offset+1>$pos2) break; if($offset+1<=$pos2 && $offset+$len>=$pos2) { $chunk=substr($chunk,0,$pos2-$offset-1)."<span style='color:red'>".substr($chunk,$pos2-$offset-1,1)."</span>".substr($chunk,$pos2-$offset); } if($offset+1<=$pos1 && $offset+$len>=$pos1) { $chunk=substr($chunk,0,$pos1-$offset-1)."<span style='color:red'>".substr($chunk,$pos1-$offset-1,1)."</span>".substr($chunk,$pos1-$offset); } $offset+=$len; } return $arrs; } print_r(tag("55798-45366-11255-48084-35644-28027-85391-45536-85002-55350-4166-5991-0313-3681-9382-9143-2852-8142-8643-0235-875-383-839-92-91-00-81",25,87)); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qe8S5
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'tag'
          2        SEND_VAL                                                 '55798-45366-11255-48084-35644-28027-85391-45536-85002-55350-4166-5991-0313-3681-9382-9143-2852-8142-8643-0235-875-383-839-92-91-00-81'
          3        SEND_VAL                                                 25
          4        SEND_VAL                                                 87
          5        DO_FCALL                                      0  $0      
          6        SEND_VAR                                                 $0
          7        DO_ICALL                                                 
   24     8      > RETURN                                                   1

Function tag:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 25, Position 2 = 96
Branch analysis from position: 25
2 jumps found. (Code = 126) Position 1 = 26, Position 2 = 96
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 32
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 63
Branch analysis from position: 39
2 jumps found. (Code = 46) Position 1 = 66, Position 2 = 69
Branch analysis from position: 66
2 jumps found. (Code = 43) Position 1 = 70, Position 2 = 94
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 94
Branch analysis from position: 69
Branch analysis from position: 63
Branch analysis from position: 38
Branch analysis from position: 96
Branch analysis from position: 96
filename:       /in/Qe8S5
function name:  tag
number of ops:  99
compiled vars:  !0 = $str, !1 = $pos1, !2 = $pos2, !3 = $offset, !4 = $arrs, !5 = $chunk, !6 = $len
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    4     3        ASSIGN                                                   !3, -1
    5     4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '-'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $8      
          8        ASSIGN                                                   !4, $8
    6     9        INIT_FCALL                                               'min'
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $10     
         13        INIT_ARRAY                                       ~11     $10
         14        INIT_FCALL                                               'max'
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $12     
         18        ADD_ARRAY_ELEMENT                                ~11     $12
         19        FETCH_LIST_R                                     $13     ~11, 0
         20        ASSIGN                                                   !1, $13
         21        FETCH_LIST_R                                     $15     ~11, 1
         22        ASSIGN                                                   !2, $15
         23        FREE                                                     ~11
    7    24      > FE_RESET_RW                                      $17     !4, ->96
         25    > > FE_FETCH_RW                                              $17, !5, ->96
    9    26    >   STRLEN                                           ~18     !5
         27        ASSIGN                                                   !6, ~18
   10    28        ADD                                              ~20     !3, 1
         29        IS_SMALLER                                               !2, ~20
         30      > JMPZ                                                     ~21, ->32
         31    > > JMP                                                      ->96
   11    32    >   ADD                                              ~22     !3, 1
         33        IS_SMALLER_OR_EQUAL                              ~23     ~22, !2
         34      > JMPZ_EX                                          ~23     ~23, ->38
         35    >   ADD                                              ~24     !3, !6
         36        IS_SMALLER_OR_EQUAL                              ~25     !2, ~24
         37        BOOL                                             ~23     ~25
         38    > > JMPZ                                                     ~23, ->63
   13    39    >   INIT_FCALL                                               'substr'
         40        SEND_VAR                                                 !5
         41        SEND_VAL                                                 0
         42        SUB                                              ~26     !2, !3
         43        SUB                                              ~27     ~26, 1
         44        SEND_VAL                                                 ~27
         45        DO_ICALL                                         $28     
         46        CONCAT                                           ~29     $28, '%3Cspan+style%3D%27color%3Ared%27%3E'
         47        INIT_FCALL                                               'substr'
         48        SEND_VAR                                                 !5
         49        SUB                                              ~30     !2, !3
         50        SUB                                              ~31     ~30, 1
         51        SEND_VAL                                                 ~31
         52        SEND_VAL                                                 1
         53        DO_ICALL                                         $32     
         54        CONCAT                                           ~33     ~29, $32
         55        CONCAT                                           ~34     ~33, '%3C%2Fspan%3E'
         56        INIT_FCALL                                               'substr'
         57        SEND_VAR                                                 !5
         58        SUB                                              ~35     !2, !3
         59        SEND_VAL                                                 ~35
         60        DO_ICALL                                         $36     
         61        CONCAT                                           ~37     ~34, $36
         62        ASSIGN                                                   !5, ~37
   15    63    >   ADD                                              ~39     !3, 1
         64        IS_SMALLER_OR_EQUAL                              ~40     ~39, !1
         65      > JMPZ_EX                                          ~40     ~40, ->69
         66    >   ADD                                              ~41     !3, !6
         67        IS_SMALLER_OR_EQUAL                              ~42     !1, ~41
         68        BOOL                                             ~40     ~42
         69    > > JMPZ                                                     ~40, ->94
   17    70    >   INIT_FCALL                                               'substr'
         71        SEND_VAR                                                 !5
         72        SEND_VAL                                                 0
         73        SUB                                              ~43     !1, !3
         74        SUB                                              ~44     ~43, 1
         75        SEND_VAL                                                 ~44
         76        DO_ICALL                                         $45     
         77        CONCAT                                           ~46     $45, '%3Cspan+style%3D%27color%3Ared%27%3E'
         78        INIT_FCALL                                               'substr'
         79        SEND_VAR                                                 !5
         80        SUB                                              ~47     !1, !3
         81        SUB                                              ~48     ~47, 1
         82        SEND_VAL                                                 ~48
         83        SEND_VAL                                                 1
         84        DO_ICALL                                         $49     
         85        CONCAT                                           ~50     ~46, $49
         86        CONCAT                                           ~51     ~50, '%3C%2Fspan%3E'
         87        INIT_FCALL                                               'substr'
         88        SEND_VAR                                                 !5
         89        SUB                                              ~52     !1, !3
         90        SEND_VAL                                                 ~52
         91        DO_ICALL                                         $53     
         92        CONCAT                                           ~54     ~51, $53
         93        ASSIGN                                                   !5, ~54
   19    94    >   ASSIGN_OP                                     1          !3, !6
    7    95      > JMP                                                      ->25
         96    >   FE_FREE                                                  $17
   21    97      > RETURN                                                   !4
   22    98*     > RETURN                                                   null

End of function tag

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
213.74 ms | 1406 KiB | 24 Q