3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_values_between($the_string, $starts_with, $ends_with) { //$pos = strpos($the_string , $starts_with); //if($pos===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)) { $a_start_match = substr($a_start_match,0,strpos($a_start_match , $ends_with)); if(substr($a_start_match, -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_1UVWXYZstring2"; $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/sug87
function name:  (null)
number of ops:  13
compiled vars:  !0 = $the_string, !1 = $start, !2 = $end, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   ASSIGN                                                   !0, 'some+string+here+string_1ABCDEFGHstring2+some+string+here+string_1IJKLMNOPQRSTstring2+some+string+here+string_1UVWXYZstring2'
   42     1        ASSIGN                                                   !1, 'string_1'
   43     2        ASSIGN                                                   !2, 'string2'
   45     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
   47     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function get_values_between:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 52
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 52
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 51
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 51
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 51
Branch analysis from position: 51
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
filename:       /in/sug87
function name:  get_values_between
number of ops:  55
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      
   11     3        INIT_FCALL                                               'substr'
          4        SEND_VAR                                                 !0
          5        INIT_FCALL                                               'strpos'
          6        SEND_VAR                                                 !0
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !0, $8
   13    12        INIT_FCALL                                               'array_filter'
         13        INIT_FCALL                                               'explode'
         14        SEND_VAR                                                 !1
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $10     
         17        SEND_VAR                                                 $10
         18        DO_ICALL                                         $11     
         19        ASSIGN                                                   !3, $11
   15    20        ASSIGN                                                   !4, <array>
   17    21        ASSIGN                                                   !5, 0
   19    22      > FE_RESET_R                                       $15     !3, ->52
         23    > > FE_FETCH_R                                               $15, !6, ->52
   21    24    >   STRLEN                                           ~16     !2
         25        STRLEN                                           ~17     !6
         26        IS_SMALLER_OR_EQUAL                                      ~16, ~17
         27      > JMPZ                                                     ~18, ->51
   23    28    >   INIT_FCALL                                               'substr'
         29        SEND_VAR                                                 !6
         30        SEND_VAL                                                 0
         31        INIT_FCALL                                               'strpos'
         32        SEND_VAR                                                 !6
         33        SEND_VAR                                                 !2
         34        DO_ICALL                                         $19     
         35        SEND_VAR                                                 $19
         36        DO_ICALL                                         $20     
         37        ASSIGN                                                   !6, $20
   25    38        INIT_FCALL                                               'substr'
         39        SEND_VAR                                                 !6
         40        STRLEN                                           ~22     !2
         41        MUL                                              ~23     ~22, -1
         42        SEND_VAL                                                 ~23
         43        DO_ICALL                                         $24     
         44        IS_IDENTICAL                                             !2, $24
         45      > JMPZ                                                     ~25, ->51
   27    46    >   CONCAT                                           ~26     !6, '%0A'
         47        ECHO                                                     ~26
   28    48        ASSIGN_DIM                                               !4, !5
         49        OP_DATA                                                  !6
   29    50        PRE_INC                                                  !5
   19    51    > > JMP                                                      ->23
         52    >   FE_FREE                                                  $15
   34    53      > RETURN                                                   !4
   35    54*     > RETURN                                                   null

End of function get_values_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.62 ms | 1403 KiB | 24 Q