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)) { echo "testing ".substr($a_start_match, -strlen($ends_with))." against ".$ends_with."\n"; 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/jSRD9
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
-------------------------------------------------------------------------------------
   34     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'
   36     1        ASSIGN                                                   !1, 'string_1'
   37     2        ASSIGN                                                   !2, 'string2'
   39     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 = 39
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 39
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 38
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 38
Branch analysis from position: 38
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/jSRD9
function name:  get_between
number of ops:  42
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, ->39
         11    > > FE_FETCH_R                                               $11, !6, ->39
   15    12    >   STRLEN                                           ~12     !2
         13        STRLEN                                           ~13     !6
         14        IS_SMALLER_OR_EQUAL                                      ~12, ~13
         15      > JMPZ                                                     ~14, ->38
   18    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        CONCAT                                           ~18     'testing+', $17
         23        CONCAT                                           ~19     ~18, '+against+'
         24        CONCAT                                           ~20     ~19, !2
         25        CONCAT                                           ~21     ~20, '%0A'
         26        ECHO                                                     ~21
   19    27        INIT_FCALL                                               'substr'
         28        SEND_VAR                                                 !6
         29        STRLEN                                           ~22     !2
         30        MUL                                              ~23     ~22, -1
         31        SEND_VAL                                                 ~23
         32        DO_ICALL                                         $24     
         33        IS_IDENTICAL                                             !2, $24
         34      > JMPZ                                                     ~25, ->38
   21    35    >   ASSIGN_DIM                                               !4, !5
         36        OP_DATA                                                  !6
   22    37        PRE_INC                                                  !5
   12    38    > > JMP                                                      ->11
         39    >   FE_FREE                                                  $11
   28    40      > RETURN                                                   !4
   29    41*     > RETURN                                                   null

End of function get_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.25 ms | 1402 KiB | 20 Q