3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_between($input, $start, $end) { $temp = explode($start, $input); $result_array = array(); $inc = 0; foreach($temp as $a_start_match) { if (strlen($end <= strlen($a_start_match))) { if(substr($a_start_match, -strlen($end)) === $end) { $result_array[$inc]=$a_start_match; ++$inc; } } } return $result_array; } $the_string = "some string here string_1--------string2 some string here string_1--------string2 some string here string_1--------string2"; $a = "string_1"; $b = "string2"; print_R (get_between($the_string,$a,$b));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dfvPN
function name:  (null)
number of ops:  12
compiled vars:  !0 = $the_string, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   ASSIGN                                                   !0, 'some+string+here+string_1--------string2+some+string+here+string_1--------string2+some+string+here+string_1--------string2'
   32     1        ASSIGN                                                   !1, 'string_1'
   33     2        ASSIGN                                                   !2, 'string2'
   35     3        INIT_FCALL                                               'print_r'
          4        INIT_FCALL                                               'get_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                                                 
         11      > RETURN                                                   1

Function get_between:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 28
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 28
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 27
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 27
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 27
Branch analysis from position: 27
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/dfvPN
function name:  get_between
number of ops:  31
compiled vars:  !0 = $input, !1 = $start, !2 = $end, !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                                               'explode'
          4        SEND_VAR                                                 !1
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !3, $7
    8     8        ASSIGN                                                   !4, <array>
   10     9        ASSIGN                                                   !5, 0
   12    10      > FE_RESET_R                                       $11     !3, ->28
         11    > > FE_FETCH_R                                               $11, !6, ->28
   14    12    >   STRLEN                                           ~12     !6
         13        IS_SMALLER_OR_EQUAL                              ~13     !2, ~12
         14        STRLEN                                           ~14     ~13
         15      > JMPZ                                                     ~14, ->27
   16    16    >   INIT_FCALL                                               'substr'
         17        SEND_VAR                                                 !6
         18        STRLEN                                           ~15     !2
         19        MUL                                              ~16     ~15, -1
         20        SEND_VAL                                                 ~16
         21        DO_ICALL                                         $17     
         22        IS_IDENTICAL                                             !2, $17
         23      > JMPZ                                                     ~18, ->27
   18    24    >   ASSIGN_DIM                                               !4, !5
         25        OP_DATA                                                  !6
   19    26        PRE_INC                                                  !5
   12    27    > > JMP                                                      ->11
         28    >   FE_FREE                                                  $11
   24    29      > RETURN                                                   !4
   25    30*     > RETURN                                                   null

End of function get_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.95 ms | 1403 KiB | 20 Q