3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(6,8,9,8,9,8,5,4,4,9); function Counting($array){ $freq_data = array_count_values($array); $unique_elements = array_map('intval',array_keys($freq_data)); sort($unique_elements); $percentage_data = []; $total = count($array); foreach($unique_elements as $index => $element){ $current_percentage = $freq_data[$element] / $total; $percentage_data[$element] = $index > 0 ? $percentage_data[$prev_element] + $current_percentage : $current_percentage; $prev_element = $element; } return $percentage_data; } print_r(Counting($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vodsf
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   17     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'counting'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function counting:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 36
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 36
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 31
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/vodsf
function name:  Counting
number of ops:  39
compiled vars:  !0 = $array, !1 = $freq_data, !2 = $unique_elements, !3 = $percentage_data, !4 = $total, !5 = $element, !6 = $index, !7 = $current_percentage, !8 = $prev_element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'array_count_values'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $9      
          4        ASSIGN                                                   !1, $9
    5     5        INIT_FCALL                                               'array_map'
          6        SEND_VAL                                                 'intval'
          7        INIT_FCALL                                               'array_keys'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                         $11     
         10        SEND_VAR                                                 $11
         11        DO_ICALL                                         $12     
         12        ASSIGN                                                   !2, $12
    6    13        INIT_FCALL                                               'sort'
         14        SEND_REF                                                 !2
         15        DO_ICALL                                                 
    7    16        ASSIGN                                                   !3, <array>
    8    17        COUNT                                            ~16     !0
         18        ASSIGN                                                   !4, ~16
    9    19      > FE_RESET_R                                       $18     !2, ->36
         20    > > FE_FETCH_R                                       ~19     $18, !5, ->36
         21    >   ASSIGN                                                   !6, ~19
   10    22        FETCH_DIM_R                                      ~21     !1, !5
         23        DIV                                              ~22     ~21, !4
         24        ASSIGN                                                   !7, ~22
   11    25        IS_SMALLER                                               0, !6
         26      > JMPZ                                                     ~25, ->31
         27    >   FETCH_DIM_R                                      ~26     !3, !8
         28        ADD                                              ~27     ~26, !7
         29        QM_ASSIGN                                        ~28     ~27
         30      > JMP                                                      ->32
         31    >   QM_ASSIGN                                        ~28     !7
         32    >   ASSIGN_DIM                                               !3, !5
         33        OP_DATA                                                  ~28
   12    34        ASSIGN                                                   !8, !5
    9    35      > JMP                                                      ->20
         36    >   FE_FREE                                                  $18
   14    37      > RETURN                                                   !3
   15    38*     > RETURN                                                   null

End of function counting

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
127.83 ms | 1011 KiB | 19 Q