3v4l.org

run code in 300+ PHP versions simultaneously
<?php $default = array( 'Year', 'Mining-1969-70=100', 'Mining-1975-76=100', 'Man-1980-81=100', 'Man-198081=100', ); $default2 = array( 'Year', 'Mining-1969-70=100', 'Mining-1975-76=100', 'Mining-1980-81=100', 'Man-198081=100', ); function getFollowingSimilarValues($arr, $start) { $count = count($arr); if ($start >= $count) return array(); $result = array($arr[$start]); $strpos = strpos($arr[$start],'-'); for ($i=($start+1); $i<$count; $i++) { if (strncasecmp($arr[$start], $arr[$i], $strpos) == 0) $result[] = $arr[$i]; } return $result; } print implode(", ", getFollowingSimilarValues($default, 1))."\n"; print implode(", ", getFollowingSimilarValues($default2, 1));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Bl443
function name:  (null)
number of ops:  22
compiled vars:  !0 = $default, !1 = $default2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   32     2        INIT_FCALL                                               'implode'
          3        SEND_VAL                                                 '%2C+'
          4        INIT_FCALL                                               'getfollowingsimilarvalues'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 1
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                         $5      
         10        CONCAT                                           ~6      $5, '%0A'
         11        ECHO                                                     ~6
   33    12        INIT_FCALL                                               'implode'
         13        SEND_VAL                                                 '%2C+'
         14        INIT_FCALL                                               'getfollowingsimilarvalues'
         15        SEND_VAR                                                 !1
         16        SEND_VAL                                                 1
         17        DO_FCALL                                      0  $7      
         18        SEND_VAR                                                 $7
         19        DO_ICALL                                         $8      
         20        ECHO                                                     $8
         21      > RETURN                                                   1

Function getfollowingsimilarvalues:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 19
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 31
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 19
Branch analysis from position: 34
Branch analysis from position: 19
Branch analysis from position: 31
filename:       /in/Bl443
function name:  getFollowingSimilarValues
number of ops:  36
compiled vars:  !0 = $arr, !1 = $start, !2 = $count, !3 = $result, !4 = $strpos, !5 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   19     2        COUNT                                            ~6      !0
          3        ASSIGN                                                   !2, ~6
   20     4        IS_SMALLER_OR_EQUAL                                      !2, !1
          5      > JMPZ                                                     ~8, ->7
   21     6    > > RETURN                                                   <array>
   23     7    >   FETCH_DIM_R                                      ~9      !0, !1
          8        INIT_ARRAY                                       ~10     ~9
          9        ASSIGN                                                   !3, ~10
   24    10        INIT_FCALL                                               'strpos'
         11        FETCH_DIM_R                                      ~12     !0, !1
         12        SEND_VAL                                                 ~12
         13        SEND_VAL                                                 '-'
         14        DO_ICALL                                         $13     
         15        ASSIGN                                                   !4, $13
   25    16        ADD                                              ~15     !1, 1
         17        ASSIGN                                                   !5, ~15
         18      > JMP                                                      ->32
   26    19    >   INIT_FCALL                                               'strncasecmp'
         20        FETCH_DIM_R                                      ~17     !0, !1
         21        SEND_VAL                                                 ~17
         22        FETCH_DIM_R                                      ~18     !0, !5
         23        SEND_VAL                                                 ~18
         24        SEND_VAR                                                 !4
         25        DO_ICALL                                         $19     
         26        IS_EQUAL                                                 $19, 0
         27      > JMPZ                                                     ~20, ->31
   27    28    >   FETCH_DIM_R                                      ~22     !0, !5
         29        ASSIGN_DIM                                               !3
         30        OP_DATA                                                  ~22
   25    31    >   PRE_INC                                                  !5
         32    >   IS_SMALLER                                               !5, !2
         33      > JMPNZ                                                    ~24, ->19
   29    34    > > RETURN                                                   !3
   30    35*     > RETURN                                                   null

End of function getfollowingsimilarvalues

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.51 ms | 1403 KiB | 21 Q