3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrays = [ [ "tag" => "DOCUMENT", "type" => "open", "level" => 1 ], [ "tag" => "SENDERID", "type" => "open", "level" => 1, "value" => "TEST" ], [ "tag" => "SENDERSHORTNAME", "type" => "open", "level" => 1 ], [ "tag" => "RECIPIENTID", "type" => "open", "level" => 1, "value" => "VGLEE" ] ]; $compare_array = array('DOCUMENT', 'SENDERID', 'SENDERSHORTNAME', 'RECIPIENTID'); $result = array_reduce($arrays, function($carry, $item) use ($compare_array) { if(isset($item["value"]) && in_array($item["tag"], $compare_array, true)) { $carry[$item["tag"]] = $item["value"]; } return $carry; }); extract($result, EXTR_OVERWRITE); echo $SENDERID; echo PHP_EOL; echo $RECIPIENTID;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tEsg8
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arrays, !1 = $compare_array, !2 = $result, !3 = $SENDERID, !4 = $RECIPIENTID
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   27     1        ASSIGN                                                   !1, <array>
   28     2        INIT_FCALL                                               'array_reduce'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FtEsg8%3A28%240'
          5        BIND_LEXICAL                                             ~7, !1
   33     6        SEND_VAL                                                 ~7
          7        DO_ICALL                                         $8      
   28     8        ASSIGN                                                   !2, $8
   34     9        INIT_FCALL                                               'extract'
         10        SEND_REF                                                 !2
         11        SEND_VAL                                                 0
         12        DO_ICALL                                                 
   36    13        ECHO                                                     !3
   37    14        ECHO                                                     '%0A'
   38    15        ECHO                                                     !4
   39    16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FtEsg8%3A28%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 17
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 12
filename:       /in/tEsg8
function name:  {closure}
number of ops:  19
compiled vars:  !0 = $carry, !1 = $item, !2 = $compare_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   29     3        ISSET_ISEMPTY_DIM_OBJ                         0  ~3      !1, 'value'
          4      > JMPZ_EX                                          ~3      ~3, ->12
          5    >   INIT_FCALL                                               'in_array'
          6        FETCH_DIM_R                                      ~4      !1, 'tag'
          7        SEND_VAL                                                 ~4
          8        SEND_VAR                                                 !2
          9        SEND_VAL                                                 <true>
         10        DO_ICALL                                         $5      
         11        BOOL                                             ~3      $5
         12    > > JMPZ                                                     ~3, ->17
   30    13    >   FETCH_DIM_R                                      ~6      !1, 'tag'
         14        FETCH_DIM_R                                      ~8      !1, 'value'
         15        ASSIGN_DIM                                               !0, ~6
         16        OP_DATA                                                  ~8
   32    17    > > RETURN                                                   !0
   33    18*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FtEsg8%3A28%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.86 ms | 1405 KiB | 19 Q