3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array( array("ranking" => array(array(5),array(2,4,5)), "frequency" => array(array(5),array(1,2,11))), array("ranking" => array(array(3,5),array(3,4,5)), "frequency" => array(array(1,4),array(1,2,11)) ) ); function calRanking($ranks, $freqs) { $res = array_fill(0, 5, 0); foreach($ranks as $k => $v) { foreach(array_map(null, $v, $freqs[$k]) as $e) { $res[$e[0]-1]+= $e[1]; } } return $res; } foreach($a as &$v) { $v["frequency"] = implode(',', calRanking($v["ranking"], $v["frequency"])); $v["ranking"] = implode(',',range(1,5)); } print_r($a);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 2, Position 2 = 26
Branch analysis from position: 2
2 jumps found. (Code = 126) Position 1 = 3, Position 2 = 26
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/K6fnT6
function name:  (null)
number of ops:  31
compiled vars:  !0 = $a, !1 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   23     1      > FE_RESET_RW                                      $3      !0, ->26
          2    > > FE_FETCH_RW                                              $3, !1, ->26
   24     3    >   INIT_FCALL                                               'implode'
          4        SEND_VAL                                                 '%2C'
          5        INIT_FCALL                                               'calranking'
          6        FETCH_DIM_R                                      ~5      !1, 'ranking'
          7        SEND_VAL                                                 ~5
          8        FETCH_DIM_R                                      ~6      !1, 'frequency'
          9        SEND_VAL                                                 ~6
         10        DO_FCALL                                      0  $7      
         11        SEND_VAR                                                 $7
         12        DO_ICALL                                         $8      
         13        ASSIGN_DIM                                               !1, 'frequency'
         14        OP_DATA                                                  $8
   25    15        INIT_FCALL                                               'implode'
         16        SEND_VAL                                                 '%2C'
         17        INIT_FCALL                                               'range'
         18        SEND_VAL                                                 1
         19        SEND_VAL                                                 5
         20        DO_ICALL                                         $10     
         21        SEND_VAR                                                 $10
         22        DO_ICALL                                         $11     
         23        ASSIGN_DIM                                               !1, 'ranking'
         24        OP_DATA                                                  $11
   23    25      > JMP                                                      ->2
         26    >   FE_FREE                                                  $3
   27    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function calranking:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 27
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 27
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 25
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 25
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/K6fnT6
function name:  calRanking
number of ops:  30
compiled vars:  !0 = $ranks, !1 = $freqs, !2 = $res, !3 = $v, !4 = $k, !5 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        INIT_FCALL                                               'array_fill'
          3        SEND_VAL                                                 0
          4        SEND_VAL                                                 5
          5        SEND_VAL                                                 0
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !2, $6
   15     8      > FE_RESET_R                                       $8      !0, ->27
          9    > > FE_FETCH_R                                       ~9      $8, !3, ->27
         10    >   ASSIGN                                                   !4, ~9
   16    11        INIT_FCALL                                               'array_map'
         12        SEND_VAL                                                 null
         13        SEND_VAR                                                 !3
         14        FETCH_DIM_R                                      ~11     !1, !4
         15        SEND_VAL                                                 ~11
         16        DO_ICALL                                         $12     
         17      > FE_RESET_R                                       $13     $12, ->25
         18    > > FE_FETCH_R                                               $13, !5, ->25
   17    19    >   FETCH_DIM_R                                      ~14     !5, 0
         20        SUB                                              ~15     ~14, 1
         21        FETCH_DIM_R                                      ~17     !5, 1
         22        ASSIGN_DIM_OP                +=               1          !2, ~15
         23        OP_DATA                                                  ~17
   16    24      > JMP                                                      ->18
         25    >   FE_FREE                                                  $13
   15    26      > JMP                                                      ->9
         27    >   FE_FREE                                                  $8
   20    28      > RETURN                                                   !2
   21    29*     > RETURN                                                   null

End of function calranking

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.07 ms | 1011 KiB | 19 Q