3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_values_between($the_string, $starts_with, $ends_with) { if(strpos($the_string , $starts_with)===false) return array(); $the_string = substr($the_string,strpos($the_string , $starts_with)); //echo $the_string; $temp = array_filter(explode($starts_with, $the_string)); $result_array = array(); $inc = 0; foreach($temp as $a_start_match) { if (strlen($ends_with) <= strlen($a_start_match)) { $a_start_match = substr($a_start_match,0,strpos($a_start_match , $ends_with)); echo substr($a_start_match, 0, -strlen($ends_with))." against ".$ends_with."\n"; if(substr($a_start_match, 0, -strlen($ends_with)) === $ends_with) { echo $a_start_match."\n"; $result_array[$inc]=$a_start_match; $inc++; } } } return $result_array; } $the_string = "some string here string_1ABCDEFGHstring2 some string here string_1IJKLMNOPQRSTstring2 some string here string_1UVWstring2XYZ"; $start = "string_1"; $end = "string2"; $result = get_values_between($the_string,$start,$end); //print_r($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dQZ1l
function name:  (null)
number of ops:  10
compiled vars:  !0 = $the_string, !1 = $start, !2 = $end, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   ASSIGN                                                   !0, 'some+string+here+string_1ABCDEFGHstring2+some+string+here+string_1IJKLMNOPQRSTstring2+some+string+here+string_1UVWstring2XYZ'
   46     1        ASSIGN                                                   !1, 'string_1'
   47     2        ASSIGN                                                   !2, 'string2'
   49     3        INIT_FCALL                                               'get_values_between'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !3, $7
   51     9      > RETURN                                                   1

Function get_values_between:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 30, Position 2 = 71
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 71
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 70
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 70
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 70
Branch analysis from position: 70
Branch analysis from position: 71
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 71
filename:       /in/dQZ1l
function name:  get_values_between
number of ops:  74
compiled vars:  !0 = $the_string, !1 = $starts_with, !2 = $ends_with, !3 = $temp, !4 = $result_array, !5 = $inc, !6 = $a_start_match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3        INIT_FCALL                                               'strpos'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $7      
          7        TYPE_CHECK                                    4          $7
          8      > JMPZ                                                     ~8, ->10
    8     9    > > RETURN                                                   <array>
   10    10    >   INIT_FCALL                                               'substr'
         11        SEND_VAR                                                 !0
         12        INIT_FCALL                                               'strpos'
         13        SEND_VAR                                                 !0
         14        SEND_VAR                                                 !1
         15        DO_ICALL                                         $9      
         16        SEND_VAR                                                 $9
         17        DO_ICALL                                         $10     
         18        ASSIGN                                                   !0, $10
   14    19        INIT_FCALL                                               'array_filter'
         20        INIT_FCALL                                               'explode'
         21        SEND_VAR                                                 !1
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $12     
         24        SEND_VAR                                                 $12
         25        DO_ICALL                                         $13     
         26        ASSIGN                                                   !3, $13
   16    27        ASSIGN                                                   !4, <array>
   18    28        ASSIGN                                                   !5, 0
   20    29      > FE_RESET_R                                       $17     !3, ->71
         30    > > FE_FETCH_R                                               $17, !6, ->71
   23    31    >   STRLEN                                           ~18     !2
         32        STRLEN                                           ~19     !6
         33        IS_SMALLER_OR_EQUAL                                      ~18, ~19
         34      > JMPZ                                                     ~20, ->70
   25    35    >   INIT_FCALL                                               'substr'
         36        SEND_VAR                                                 !6
         37        SEND_VAL                                                 0
         38        INIT_FCALL                                               'strpos'
         39        SEND_VAR                                                 !6
         40        SEND_VAR                                                 !2
         41        DO_ICALL                                         $21     
         42        SEND_VAR                                                 $21
         43        DO_ICALL                                         $22     
         44        ASSIGN                                                   !6, $22
   27    45        INIT_FCALL                                               'substr'
         46        SEND_VAR                                                 !6
         47        SEND_VAL                                                 0
         48        STRLEN                                           ~24     !2
         49        MUL                                              ~25     ~24, -1
         50        SEND_VAL                                                 ~25
         51        DO_ICALL                                         $26     
         52        CONCAT                                           ~27     $26, '+against+'
         53        CONCAT                                           ~28     ~27, !2
         54        CONCAT                                           ~29     ~28, '%0A'
         55        ECHO                                                     ~29
   29    56        INIT_FCALL                                               'substr'
         57        SEND_VAR                                                 !6
         58        SEND_VAL                                                 0
         59        STRLEN                                           ~30     !2
         60        MUL                                              ~31     ~30, -1
         61        SEND_VAL                                                 ~31
         62        DO_ICALL                                         $32     
         63        IS_IDENTICAL                                             !2, $32
         64      > JMPZ                                                     ~33, ->70
   31    65    >   CONCAT                                           ~34     !6, '%0A'
         66        ECHO                                                     ~34
   32    67        ASSIGN_DIM                                               !4, !5
         68        OP_DATA                                                  !6
   33    69        PRE_INC                                                  !5
   20    70    > > JMP                                                      ->30
         71    >   FE_FREE                                                  $17
   38    72      > RETURN                                                   !4
   39    73*     > RETURN                                                   null

End of function get_values_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.41 ms | 1407 KiB | 22 Q