3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_between($the_string, $starts_with, $ends_with) { echo "before".$the_string."\n"; $the_string = substr($the_string,strpos ($the_string , $starts_with)); echo "now".$the_string."\n\n\n"; $temp = array_filter(explode($starts_with, $the_string)); $result_array = array(); $inc = 0; foreach($temp as $a_start_match) { //echo $a_start_match."\n"; if (strlen($ends_with) <= strlen($a_start_match)) { $a_start_match = substr($a_start_match,0,strpos($a_start_match , $ends_with)); echo $a_start_match."\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/TLfTD
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
-------------------------------------------------------------------------------------
   40     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'
   42     1        ASSIGN                                                   !1, 'string_1'
   43     2        ASSIGN                                                   !2, 'string2'
   45     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 = 29, Position 2 = 58
Branch analysis from position: 29
2 jumps found. (Code = 78) Position 1 = 30, Position 2 = 58
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 57
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 57
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 57
Branch analysis from position: 57
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
filename:       /in/TLfTD
function name:  get_between
number of ops:  61
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        CONCAT                                           ~7      'before', !0
          4        CONCAT                                           ~8      ~7, '%0A'
          5        ECHO                                                     ~8
    8     6        INIT_FCALL                                               'substr'
          7        SEND_VAR                                                 !0
          8        INIT_FCALL                                               'strpos'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $9      
         12        SEND_VAR                                                 $9
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !0, $10
    9    15        CONCAT                                           ~12     'now', !0
         16        CONCAT                                           ~13     ~12, '%0A%0A%0A'
         17        ECHO                                                     ~13
   11    18        INIT_FCALL                                               'array_filter'
         19        INIT_FCALL                                               'explode'
         20        SEND_VAR                                                 !1
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $14     
         23        SEND_VAR                                                 $14
         24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !3, $15
   12    26        ASSIGN                                                   !4, <array>
   14    27        ASSIGN                                                   !5, 0
   16    28      > FE_RESET_R                                       $19     !3, ->58
         29    > > FE_FETCH_R                                               $19, !6, ->58
   19    30    >   STRLEN                                           ~20     !2
         31        STRLEN                                           ~21     !6
         32        IS_SMALLER_OR_EQUAL                                      ~20, ~21
         33      > JMPZ                                                     ~22, ->57
   22    34    >   INIT_FCALL                                               'substr'
         35        SEND_VAR                                                 !6
         36        SEND_VAL                                                 0
         37        INIT_FCALL                                               'strpos'
         38        SEND_VAR                                                 !6
         39        SEND_VAR                                                 !2
         40        DO_ICALL                                         $23     
         41        SEND_VAR                                                 $23
         42        DO_ICALL                                         $24     
         43        ASSIGN                                                   !6, $24
   24    44        CONCAT                                           ~26     !6, '%0A'
         45        ECHO                                                     ~26
   25    46        INIT_FCALL                                               'substr'
         47        SEND_VAR                                                 !6
         48        STRLEN                                           ~27     !2
         49        MUL                                              ~28     ~27, -1
         50        SEND_VAL                                                 ~28
         51        DO_ICALL                                         $29     
         52        IS_IDENTICAL                                             !2, $29
         53      > JMPZ                                                     ~30, ->57
   27    54    >   ASSIGN_DIM                                               !4, !5
         55        OP_DATA                                                  !6
   28    56        PRE_INC                                                  !5
   16    57    > > JMP                                                      ->29
         58    >   FE_FREE                                                  $19
   34    59      > RETURN                                                   !4
   35    60*     > RETURN                                                   null

End of function get_between

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.88 ms | 1403 KiB | 24 Q