3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_between($the_string, $starts_with, $ends_with) { $temp = explode($starts_with, $the_string); $result_array = array(); $inc = 0; foreach($temp as $a_start_match) { echo $inc; if (strlen($ends_with) <= strlen($a_start_match)) { if(substr($a_start_match, -strlen($ends_with)) === $ends_with) { $result_array[$inc]=$a_start_match; $inc++; } } } return $result_array; } $the_string = "some string here string_1---1-----string2 some string here string_1----2----string2 some string here string_1----3----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/e3p4P
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
-------------------------------------------------------------------------------------
   32     0  E >   ASSIGN                                                   !0, 'some+string+here+string_1---1-----string2+some+string+here+string_1----2----string2+some+string+here+string_1----3----string2'
   34     1        ASSIGN                                                   !1, 'string_1'
   35     2        ASSIGN                                                   !2, 'string2'
   37     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 = 29
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 29
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 28
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 28
Branch analysis from position: 28
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/e3p4P
function name:  get_between
number of ops:  32
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                                               '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, ->29
         11    > > FE_FETCH_R                                               $11, !6, ->29
   14    12    >   ECHO                                                     !5
   15    13        STRLEN                                           ~12     !2
         14        STRLEN                                           ~13     !6
         15        IS_SMALLER_OR_EQUAL                                      ~12, ~13
         16      > JMPZ                                                     ~14, ->28
   17    17    >   INIT_FCALL                                               'substr'
         18        SEND_VAR                                                 !6
         19        STRLEN                                           ~15     !2
         20        MUL                                              ~16     ~15, -1
         21        SEND_VAL                                                 ~16
         22        DO_ICALL                                         $17     
         23        IS_IDENTICAL                                             !2, $17
         24      > JMPZ                                                     ~18, ->28
   19    25    >   ASSIGN_DIM                                               !4, !5
         26        OP_DATA                                                  !6
   20    27        PRE_INC                                                  !5
   12    28    > > JMP                                                      ->11
         29    >   FE_FREE                                                  $11
   26    30      > RETURN                                                   !4
   27    31*     > RETURN                                                   null

End of function get_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.33 ms | 1403 KiB | 20 Q