3v4l.org

run code in 500+ PHP versions simultaneously
<?php $data = [1, 5, 12, 15, 20, 25,]; function getDifferences($aValues) { $aDiff = []; $iSize = count($aValues); for ($i = 0; $i < $iSize; $i++) { for ($j = $i + 1; $j < $iSize; $j++) { $aDiff[$aValues[$i]][] = abs($aValues[$i] - $aValues[$j]); } } return $aDiff; } function printDifferences($aValues){ foreach ($aValues as $iNumber => $aDiffs){ echo "Differences for $iNumber: " . implode(', ', $aDiffs) . PHP_EOL; } } $aDiff = getDifferences($data); printDifferences($aDiff);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9oiqs
function name:  (null)
number of ops:  9
compiled vars:  !0 = $data, !1 = $aDiff
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   25     1        INIT_FCALL                                                   'getdifferences'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $3      
          4        ASSIGN                                                       !1, $3
   26     5        INIT_FCALL                                                   'printdifferences'
          6        SEND_VAR                                                     !1
          7        DO_FCALL                                          0          
          8      > RETURN                                                       1

Function getdifferences:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 6
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 6
Branch analysis from position: 25
Branch analysis from position: 6
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 9
Branch analysis from position: 22
Branch analysis from position: 9
filename:       /in/9oiqs
function name:  getDifferences
number of ops:  27
compiled vars:  !0 = $aValues, !1 = $aDiff, !2 = $iSize, !3 = $i, !4 = $j
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    7     1        ASSIGN                                                       !1, <array>
    8     2        COUNT                                                ~6      !0
          3        ASSIGN                                                       !2, ~6
    9     4        ASSIGN                                                       !3, 0
          5      > JMP                                                          ->23
   11     6    >   ADD                                                  ~9      !3, 1
          7        ASSIGN                                                       !4, ~9
          8      > JMP                                                          ->20
   13     9    >   FETCH_DIM_R                                          ~11     !0, !3
         10        INIT_FCALL                                                   'abs'
         11        FETCH_DIM_R                                          ~14     !0, !3
         12        FETCH_DIM_R                                          ~15     !0, !4
         13        SUB                                                  ~16     ~14, ~15
         14        SEND_VAL                                                     ~16
         15        DO_ICALL                                             $17     
         16        FETCH_DIM_W                                          $12     !1, ~11
         17        ASSIGN_DIM                                                   $12
         18        OP_DATA                                                      $17
   11    19        PRE_INC                                                      !4
         20    >   IS_SMALLER                                                   !4, !2
         21      > JMPNZ                                                        ~19, ->9
    9    22    >   PRE_INC                                                      !3
         23    >   IS_SMALLER                                                   !3, !2
         24      > JMPNZ                                                        ~21, ->6
   16    25    > > RETURN                                                       !1
   17    26*     > RETURN                                                       null

End of function getdifferences

Function printdifferences:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/9oiqs
function name:  printDifferences
number of ops:  14
compiled vars:  !0 = $aValues, !1 = $aDiffs, !2 = $iNumber
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   RECV                                                 !0      
   20     1      > FE_RESET_R                                           $3      !0, ->12
          2    > > FE_FETCH_R                                           ~4      $3, !1, ->12
          3    >   ASSIGN                                                       !2, ~4
   21     4        ROPE_INIT                                         3  ~7      'Differences+for+'
          5        ROPE_ADD                                          1  ~7      ~7, !2
          6        ROPE_END                                          2  ~6      ~7, '%3A+'
          7        FRAMELESS_ICALL_2                implode             ~9      '%2C+', !1
          8        CONCAT                                               ~10     ~6, ~9
          9        CONCAT                                               ~11     ~10, '%0A'
         10        ECHO                                                         ~11
   20    11      > JMP                                                          ->2
         12    >   FE_FREE                                                      $3
   23    13      > RETURN                                                       null

End of function printdifferences

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
170.2 ms | 2637 KiB | 16 Q