3v4l.org

run code in 300+ PHP versions simultaneously
<?php function common_parts($data) { for ($b = 1; ; $b *= 10) { $base = intdiv($data[0], $b); $matches = array_filter($data, function ($v) use ($b, $base) { return intdiv($v, $b) != $base; }); if (count($matches) == 0) break; } $base *= $b; for ($i = 1; $i < count($data); $i++) { $data[$i] = $data[$i] - $base; } return $data; } print_r(common_parts(array(670006151,670006152,670006251))); print_r(common_parts(array(670006151,670006154,670006158))); print_r(common_parts(array(670006151,670006154,670006161)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4avn9
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'common_parts'
          2        SEND_VAL                                                 <array>
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   17     6        INIT_FCALL                                               'print_r'
          7        INIT_FCALL                                               'common_parts'
          8        SEND_VAL                                                 <array>
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   18    12        INIT_FCALL                                               'print_r'
         13        INIT_FCALL                                               'common_parts'
         14        SEND_VAL                                                 <array>
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function common_parts:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 3
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 26
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 26
Branch analysis from position: 34
Branch analysis from position: 26
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 3
Branch analysis from position: 23
Branch analysis from position: 3
filename:       /in/4avn9
function name:  common_parts
number of ops:  36
compiled vars:  !0 = $data, !1 = $b, !2 = $base, !3 = $matches, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        ASSIGN                                                   !1, 1
          2      > JMP                                                      ->22
    5     3    >   INIT_FCALL                                               'intdiv'
          4        FETCH_DIM_R                                      ~6      !0, 0
          5        SEND_VAL                                                 ~6
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !2, $7
    6     9        INIT_FCALL                                               'array_filter'
         10        SEND_VAR                                                 !0
         11        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
         12        BIND_LEXICAL                                             ~9, !1
         13        BIND_LEXICAL                                             ~9, !2
         14        SEND_VAL                                                 ~9
         15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !3, $10
    7    17        COUNT                                            ~12     !3
         18        IS_EQUAL                                                 ~12, 0
         19      > JMPZ                                                     ~13, ->21
         20    > > JMP                                                      ->23
    4    21    >   ASSIGN_OP                                     3          !1, 10
         22    > > JMPNZ                                                    <true>, ->3
    9    23    >   ASSIGN_OP                                     3          !2, !1
   10    24        ASSIGN                                                   !4, 1
         25      > JMP                                                      ->31
   11    26    >   FETCH_DIM_R                                      ~18     !0, !4
         27        SUB                                              ~19     ~18, !2
         28        ASSIGN_DIM                                               !0, !4
         29        OP_DATA                                                  ~19
   10    30        PRE_INC                                                  !4
         31    >   COUNT                                            ~21     !0
         32        IS_SMALLER                                               !4, ~21
         33      > JMPNZ                                                    ~22, ->26
   13    34    > > RETURN                                                   !0
   14    35*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4avn9
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $v, !1 = $b, !2 = $base
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
          3        INIT_FCALL                                               'intdiv'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        IS_NOT_EQUAL                                     ~4      !2, $3
          8      > RETURN                                                   ~4
          9*     > RETURN                                                   null

End of Dynamic Function 0

End of function common_parts

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.51 ms | 1469 KiB | 19 Q