3v4l.org

run code in 300+ PHP versions simultaneously
<?php $Arr1=Array ( 0 => Array ( "id" => "4123", "test_number" => "1", "sat_total" => "1050" ), 1 => Array ( "id" => "4123", "test_number" => "2", "sat_total" => "1130" ), 2 => Array ( "id" => "4123", "test_number" => "3", "sat_total" => "1120" ), 3 => Array ( "id" => "5555", "test_number" => "1", "sat_total" => "1130" ), 4 => Array ( "id" => "5555", "test_number" => "2", "sat_total" => "1160" ) ); $ids = array_column($Arr1, "id"); $sat = array_column($Arr1, "sat_total"); Foreach(array_unique($ids) as $id){ $new[$id] = ["id" => $id]; $tmp = array_values(array_intersect_key($sat,array_intersect_key($Arr1, array_intersect($ids, [$id])))); For($i=1;$i<=count($tmp);$i++) $new[$id]["Score" . $i] = $tmp[$i-1]; } Var_dump($new);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 49
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 49
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 38
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 48, Position 2 = 38
Branch analysis from position: 48
Branch analysis from position: 38
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
filename:       /in/ag3To
function name:  (null)
number of ops:  54
compiled vars:  !0 = $Arr1, !1 = $ids, !2 = $sat, !3 = $id, !4 = $new, !5 = $tmp, !6 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   37     1        INIT_FCALL                                               'array_column'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'id'
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   38     6        INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 'sat_total'
          9        DO_ICALL                                         $10     
         10        ASSIGN                                                   !2, $10
   40    11        INIT_FCALL                                               'array_unique'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $12     
         14      > FE_RESET_R                                       $13     $12, ->49
         15    > > FE_FETCH_R                                               $13, !3, ->49
   41    16    >   INIT_ARRAY                                       ~15     !3, 'id'
         17        ASSIGN_DIM                                               !4, !3
         18        OP_DATA                                                  ~15
   42    19        INIT_FCALL                                               'array_values'
         20        INIT_FCALL                                               'array_intersect_key'
         21        SEND_VAR                                                 !2
         22        INIT_FCALL                                               'array_intersect_key'
         23        SEND_VAR                                                 !0
         24        INIT_FCALL                                               'array_intersect'
         25        SEND_VAR                                                 !1
         26        INIT_ARRAY                                       ~16     !3
         27        SEND_VAL                                                 ~16
         28        DO_ICALL                                         $17     
         29        SEND_VAR                                                 $17
         30        DO_ICALL                                         $18     
         31        SEND_VAR                                                 $18
         32        DO_ICALL                                         $19     
         33        SEND_VAR                                                 $19
         34        DO_ICALL                                         $20     
         35        ASSIGN                                                   !5, $20
   43    36        ASSIGN                                                   !6, 1
         37      > JMP                                                      ->45
         38    >   CONCAT                                           ~24     'Score', !6
         39        SUB                                              ~26     !6, 1
         40        FETCH_DIM_R                                      ~27     !5, ~26
         41        FETCH_DIM_W                                      $23     !4, !3
         42        ASSIGN_DIM                                               $23, ~24
         43        OP_DATA                                                  ~27
         44        PRE_INC                                                  !6
         45    >   COUNT                                            ~29     !5
         46        IS_SMALLER_OR_EQUAL                                      !6, ~29
         47      > JMPNZ                                                    ~30, ->38
   40    48    > > JMP                                                      ->15
         49    >   FE_FREE                                                  $13
   45    50        INIT_FCALL                                               'var_dump'
         51        SEND_VAR                                                 !4
         52        DO_ICALL                                                 
         53      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.53 ms | 1008 KiB | 19 Q