3v4l.org

run code in 300+ PHP versions simultaneously
<?php $source = [ [ "mail_id" => "29848947", "last_name" => "Doe", "first_name" => "Jon", "email" => "jdoe@gmail.com", "status" => "opened" ], [ "mail_id" => "340980398", "last_name" => "Doe", "first_name" => "Jane", "email" => "janedoe@gmail.com", "status" => "sent" ], [ "mail_id" => "877586", "last_name" => "Dwaye", "first_name" => "Jhon", "email" => "Jhondw@yahoo.com", "status" => "clicked" ], [ "mail_id" => "225253463", "last_name" => "Doe", "first_name" => "Jon", "email" => "jdoe@gmail.com", "status" => "opened" ], [ "mail_id" => "849849w4", "last_name" => "Doe", "first_name" => "Jane", "email" => "janedoe@gmail.com", "status" => "sent" ] ]; $result = array_values(array_reduce($source, function($carry, $event) { if(!array_key_exists($event['email'], $carry)) { $carry[$event['email']] = [ "first_name" => $event["first_name"], "last_name" => $event["last_name"], "email" => $event["email"], "opened" => 0, "blocked" => 0, "hard_bounced" => 0, "sent" => 0, "clicked" => 0 ]; } $carry[$event['email']][$event["status"]]++; return $carry; }, [])); print_r($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lhlU0
function name:  (null)
number of ops:  15
compiled vars:  !0 = $source, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   42     1        INIT_FCALL                                               'array_values'
          2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FlhlU0%3A42%240'
   59     5        SEND_VAL                                                 ~3
          6        SEND_VAL                                                 <array>
          7        DO_ICALL                                         $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                         $5      
   42    10        ASSIGN                                                   !1, $5
   61    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FlhlU0%3A42%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/lhlU0
function name:  {closure}
number of ops:  27
compiled vars:  !0 = $carry, !1 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   43     2        FETCH_DIM_R                                      ~2      !1, 'email'
          3        ARRAY_KEY_EXISTS                                 ~3      ~2, !0
          4        BOOL_NOT                                         ~4      ~3
          5      > JMPZ                                                     ~4, ->20
   44     6    >   FETCH_DIM_R                                      ~5      !1, 'email'
   45     7        FETCH_DIM_R                                      ~7      !1, 'first_name'
          8        INIT_ARRAY                                       ~8      ~7, 'first_name'
   46     9        FETCH_DIM_R                                      ~9      !1, 'last_name'
         10        ADD_ARRAY_ELEMENT                                ~8      ~9, 'last_name'
   47    11        FETCH_DIM_R                                      ~10     !1, 'email'
         12        ADD_ARRAY_ELEMENT                                ~8      ~10, 'email'
   48    13        ADD_ARRAY_ELEMENT                                ~8      0, 'opened'
   49    14        ADD_ARRAY_ELEMENT                                ~8      0, 'blocked'
   50    15        ADD_ARRAY_ELEMENT                                ~8      0, 'hard_bounced'
   51    16        ADD_ARRAY_ELEMENT                                ~8      0, 'sent'
   52    17        ADD_ARRAY_ELEMENT                                ~8      0, 'clicked'
   44    18        ASSIGN_DIM                                               !0, ~5
   52    19        OP_DATA                                                  ~8
   56    20    >   FETCH_DIM_R                                      ~11     !1, 'email'
         21        FETCH_DIM_R                                      ~13     !1, 'status'
         22        FETCH_DIM_RW                                     $12     !0, ~11
         23        FETCH_DIM_RW                                     $14     $12, ~13
         24        PRE_INC                                                  $14
   58    25      > RETURN                                                   !0
   59    26*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FlhlU0%3A42%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.85 ms | 1405 KiB | 19 Q