3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [20,22,29,40,67,35,98,200,205,220]; function subArrayValues($array) { static $firstRound = 0; if (count($array) < 2){ echo $array[0]; return; } $prevVal = null; $newArray = []; foreach ($array as $val){ if ($prevVal !== null){ $result = $val - $prevVal; $newArray[] = $result; } $prevVal = $val; } if ($firstRound) echo implode(",", $array) . "\n"; $firstRound++; subArrayValues($newArray); } subArrayValues($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JO3RX
function name:  (null)
number of ops:  5
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   30     1        INIT_FCALL                                               'subarrayvalues'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Function subarrayvalues:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 20
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 18
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 20
filename:       /in/JO3RX
function name:  subArrayValues
number of ops:  33
compiled vars:  !0 = $array, !1 = $firstRound, !2 = $prevVal, !3 = $newArray, !4 = $val, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        BIND_STATIC                                              !1
   10     2        COUNT                                            ~6      !0
          3        IS_SMALLER                                               ~6, 2
          4      > JMPZ                                                     ~7, ->8
   11     5    >   FETCH_DIM_R                                      ~8      !0, 0
          6        ECHO                                                     ~8
   12     7      > RETURN                                                   null
   14     8    >   ASSIGN                                                   !2, null
   15     9        ASSIGN                                                   !3, <array>
   16    10      > FE_RESET_R                                       $11     !0, ->20
         11    > > FE_FETCH_R                                               $11, !4, ->20
   18    12    >   TYPE_CHECK                                  1020          !2
         13      > JMPZ                                                     ~12, ->18
   19    14    >   SUB                                              ~13     !4, !2
         15        ASSIGN                                                   !5, ~13
   20    16        ASSIGN_DIM                                               !3
         17        OP_DATA                                                  !5
   22    18    >   ASSIGN                                                   !2, !4
   16    19      > JMP                                                      ->11
         20    >   FE_FREE                                                  $11
   24    21      > JMPZ                                                     !1, ->28
         22    >   INIT_FCALL                                               'implode'
         23        SEND_VAL                                                 '%2C'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $17     
         26        CONCAT                                           ~18     $17, '%0A'
         27        ECHO                                                     ~18
   25    28    >   PRE_INC                                                  !1
   26    29        INIT_FCALL_BY_NAME                                       'subArrayValues'
         30        SEND_VAR_EX                                              !3
         31        DO_FCALL                                      0          
   28    32      > RETURN                                                   null

End of function subarrayvalues

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.89 ms | 1007 KiB | 15 Q