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_map(function($email) use($source) { $events = array_values(array_filter($source, function($event) use($email) { return $event['email'] == $email; })); return [ "first_name" => $events[0]["first_name"], "last_name" => $events[0]["last_name"], "email" => $email, "opened" => count(array_filter($events, function($event) { return $event["status"] == "opened"; })), "blocked" => count(array_filter($events, function($event) { return $event["status"] == "blocked"; })), "hard_bounced" => count(array_filter($events, function($event) { return $event["status"] == "hard_bounced"; })), "soft_bounced" => count(array_filter($events, function($event) { return $event["status"] == "soft_bounced"; })), "sent" => count(array_filter($events, function($event) { return $event["status"] == "sent"; })), "clicked" => count(array_filter($events, function($event) { return $event["status"] == "clicked"; })), ]; }, array_unique(array_column($source, "email"))); print_r($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KSGeX
function name:  (null)
number of ops:  19
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_map'
          2        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          3        BIND_LEXICAL                                             ~3, !0
   59     4        SEND_VAL                                                 ~3
          5        INIT_FCALL                                               'array_unique'
          6        INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 'email'
          9        DO_ICALL                                         $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                         $5      
         12        SEND_VAR                                                 $5
   42    13        DO_ICALL                                         $6      
         14        ASSIGN                                                   !1, $6
   61    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                                 
         18      > 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/KSGeX
function name:  {closure}
number of ops:  63
compiled vars:  !0 = $email, !1 = $source, !2 = $events
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   43     2        INIT_FCALL                                               'array_values'
          3        INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !1
          5        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          6        BIND_LEXICAL                                             ~3, !0
   45     7        SEND_VAL                                                 ~3
   43     8        DO_ICALL                                         $4      
   45     9        SEND_VAR                                                 $4
   43    10        DO_ICALL                                         $5      
         11        ASSIGN                                                   !2, $5
   49    12        FETCH_DIM_R                                      ~7      !2, 0
         13        FETCH_DIM_R                                      ~8      ~7, 'first_name'
         14        INIT_ARRAY                                       ~9      ~8, 'first_name'
   50    15        FETCH_DIM_R                                      ~10     !2, 0
         16        FETCH_DIM_R                                      ~11     ~10, 'last_name'
         17        ADD_ARRAY_ELEMENT                                ~9      ~11, 'last_name'
   51    18        ADD_ARRAY_ELEMENT                                ~9      !0, 'email'
   52    19        INIT_FCALL                                               'array_filter'
         20        SEND_VAR                                                 !2
         21        DECLARE_LAMBDA_FUNCTION                          ~12     [1]
         22        SEND_VAL                                                 ~12
         23        DO_ICALL                                         $13     
         24        COUNT                                            ~14     $13
         25        ADD_ARRAY_ELEMENT                                ~9      ~14, 'opened'
   53    26        INIT_FCALL                                               'array_filter'
         27        SEND_VAR                                                 !2
         28        DECLARE_LAMBDA_FUNCTION                          ~15     [2]
         29        SEND_VAL                                                 ~15
         30        DO_ICALL                                         $16     
         31        COUNT                                            ~17     $16
         32        ADD_ARRAY_ELEMENT                                ~9      ~17, 'blocked'
   54    33        INIT_FCALL                                               'array_filter'
         34        SEND_VAR                                                 !2
         35        DECLARE_LAMBDA_FUNCTION                          ~18     [3]
         36        SEND_VAL                                                 ~18
         37        DO_ICALL                                         $19     
         38        COUNT                                            ~20     $19
         39        ADD_ARRAY_ELEMENT                                ~9      ~20, 'hard_bounced'
   55    40        INIT_FCALL                                               'array_filter'
         41        SEND_VAR                                                 !2
         42        DECLARE_LAMBDA_FUNCTION                          ~21     [4]
         43        SEND_VAL                                                 ~21
         44        DO_ICALL                                         $22     
         45        COUNT                                            ~23     $22
         46        ADD_ARRAY_ELEMENT                                ~9      ~23, 'soft_bounced'
   56    47        INIT_FCALL                                               'array_filter'
         48        SEND_VAR                                                 !2
         49        DECLARE_LAMBDA_FUNCTION                          ~24     [5]
         50        SEND_VAL                                                 ~24
         51        DO_ICALL                                         $25     
         52        COUNT                                            ~26     $25
         53        ADD_ARRAY_ELEMENT                                ~9      ~26, 'sent'
   57    54        INIT_FCALL                                               'array_filter'
         55        SEND_VAR                                                 !2
         56        DECLARE_LAMBDA_FUNCTION                          ~27     [6]
         57        SEND_VAL                                                 ~27
         58        DO_ICALL                                         $28     
         59        COUNT                                            ~29     $28
         60        ADD_ARRAY_ELEMENT                                ~9      ~29, 'clicked'
         61      > RETURN                                                   ~9
   59    62*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KSGeX
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $event, !1 = $email
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   44     2        FETCH_DIM_R                                      ~2      !0, 'email'
          3        IS_EQUAL                                         ~3      !1, ~2
          4      > RETURN                                                   ~3
   45     5*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KSGeX
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   52     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'status'
          2        IS_EQUAL                                         ~2      ~1, 'opened'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KSGeX
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'status'
          2        IS_EQUAL                                         ~2      ~1, 'blocked'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KSGeX
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'status'
          2        IS_EQUAL                                         ~2      ~1, 'hard_bounced'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 3

Dynamic Function 4
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KSGeX
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'status'
          2        IS_EQUAL                                         ~2      ~1, 'soft_bounced'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 4

Dynamic Function 5
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KSGeX
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'status'
          2        IS_EQUAL                                         ~2      ~1, 'sent'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 5

Dynamic Function 6
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KSGeX
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $event
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   RECV                                             !0      
          1        FETCH_DIM_R                                      ~1      !0, 'status'
          2        IS_EQUAL                                         ~2      ~1, 'clicked'
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 6

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.35 ms | 1018 KiB | 19 Q