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(); echo "here"; $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/jhjDE
function name:  (null)
number of ops:  10
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      > RETURN                                                   1

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

End of function get_values_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.08 ms | 1402 KiB | 22 Q