3v4l.org

run code in 300+ PHP versions simultaneously
<?php $attributes = [ [ "attributeName"=> "Name", "value"=> "Paul" ], [ "attributeName"=> "Name", "value"=> "Steve" ], [ "attributeName"=> "Name", "value"=> "John" ], [ "attributeName"=> "Name", "value"=> "Andrew" ], [ "attributeName"=> "Destination", "value"=> "London" ], [ "attributeName"=> "Destination", "value"=> "Paris" ], [ "attributeName"=> "Destination", "value"=> "Ankara" ], [ "attributeName"=> "Destination", "value"=> "Kuwait" ], ]; $output = array_reduce($attributes, function ($carry, $arr) { $carry[$arr['attributeName']][] = $arr['value']; return $carry; }, array()); print_r($output); echo "<table>\n"; foreach ($output as $key => $values) { echo "<tr><td>$key</td><td>" . implode('</td><td>', $values) . "</td></tr>\n"; } echo '</table>';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 26
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 26
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/O8HHk
function name:  (null)
number of ops:  29
compiled vars:  !0 = $attributes, !1 = $output, !2 = $values, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   40     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   43     4        SEND_VAL                                                 ~5
          5        SEND_VAL                                                 <array>
   40     6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !1, $6
   45     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                                 
   47    11        ECHO                                                     '%3Ctable%3E%0A'
   48    12      > FE_RESET_R                                       $9      !1, ->26
         13    > > FE_FETCH_R                                       ~10     $9, !2, ->26
         14    >   ASSIGN                                                   !3, ~10
   49    15        ROPE_INIT                                     3  ~13     '%3Ctr%3E%3Ctd%3E'
         16        ROPE_ADD                                      1  ~13     ~13, !3
         17        ROPE_END                                      2  ~12     ~13, '%3C%2Ftd%3E%3Ctd%3E'
         18        INIT_FCALL                                               'implode'
         19        SEND_VAL                                                 '%3C%2Ftd%3E%3Ctd%3E'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $15     
         22        CONCAT                                           ~16     ~12, $15
         23        CONCAT                                           ~17     ~16, '%3C%2Ftd%3E%3C%2Ftr%3E%0A'
         24        ECHO                                                     ~17
   48    25      > JMP                                                      ->13
         26    >   FE_FREE                                                  $9
   51    27        ECHO                                                     '%3C%2Ftable%3E'
         28      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O8HHk
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $carry, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   40     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   41     2        FETCH_DIM_R                                      ~2      !1, 'attributeName'
          3        FETCH_DIM_R                                      ~5      !1, 'value'
          4        FETCH_DIM_W                                      $3      !0, ~2
          5        ASSIGN_DIM                                               $3
          6        OP_DATA                                                  ~5
   42     7      > RETURN                                                   !0
   43     8*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.55 ms | 1009 KiB | 16 Q