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)); $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)) { if(strpos($a_start_match , $ends_with)!==false) { $a_start_match = substr($a_start_match,0,strpos($a_start_match , $ends_with)); $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"; print_r(get_values_between($the_string,$start,$end)); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TnshS
function name:  (null)
number of ops:  12
compiled vars:  !0 = $the_string, !1 = $start, !2 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   ASSIGN                                                   !0, 'some+string+here+string_1ABCDEFGHstring2+some+string+here+string_1IJKLMNOPQRSTstring2+some+string+here+string_1UVWstring2XYZ'
   37     1        ASSIGN                                                   !1, 'string_1'
   38     2        ASSIGN                                                   !2, 'string2'
   40     3        INIT_FCALL                                               'print_r'
          4        INIT_FCALL                                               'get_values_between'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !2
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   42    11      > 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 = 51
Branch analysis from position: 30
2 jumps found. (Code = 78) Position 1 = 31, Position 2 = 51
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 50
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 50
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
filename:       /in/TnshS
function name:  get_values_between
number of ops:  54
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
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     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
    6     9    > > RETURN                                                   <array>
    8    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
   10    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
   12    27        ASSIGN                                                   !4, <array>
   14    28        ASSIGN                                                   !5, 0
   16    29      > FE_RESET_R                                       $17     !3, ->51
         30    > > FE_FETCH_R                                               $17, !6, ->51
   20    31    >   INIT_FCALL                                               'strpos'
         32        SEND_VAR                                                 !6
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $18     
         35        TYPE_CHECK                                  1018          $18
         36      > JMPZ                                                     ~19, ->50
   22    37    >   INIT_FCALL                                               'substr'
         38        SEND_VAR                                                 !6
         39        SEND_VAL                                                 0
         40        INIT_FCALL                                               'strpos'
         41        SEND_VAR                                                 !6
         42        SEND_VAR                                                 !2
         43        DO_ICALL                                         $20     
         44        SEND_VAR                                                 $20
         45        DO_ICALL                                         $21     
         46        ASSIGN                                                   !6, $21
   23    47        ASSIGN_DIM                                               !4, !5
         48        OP_DATA                                                  !6
   24    49        PRE_INC                                                  !5
   16    50    > > JMP                                                      ->30
         51    >   FE_FREE                                                  $17
   29    52      > RETURN                                                   !4
   30    53*     > RETURN                                                   null

End of function get_values_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.38 ms | 1403 KiB | 24 Q