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

End of function get_values_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.57 ms | 1403 KiB | 24 Q