3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array("purchase_order_details_id"=>array( 0=>"POD1", 1=>"POD1", 2=>"POD2", ), "quantity_received"=>array( 0=>5, 1=>10, 2=>20 ) ); $pods = array_unique($arr["purchase_order_details_id"]); Foreach($pods as $pod){ $PO = array_intersect($arr["purchase_order_details_id"], [$pod]); $qt = array_intersect_key($arr["quantity_received"], $PO); $new[$pod] = ["purchase_order_details_id" => $PO, "quantity_received" => $qt]; } Var_dump($new); extract($new);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 26
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 26
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/dBpuJ
function name:  (null)
number of ops:  34
compiled vars:  !0 = $arr, !1 = $pods, !2 = $pod, !3 = $PO, !4 = $qt, !5 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        INIT_FCALL                                               'array_unique'
          2        FETCH_DIM_R                                      ~7      !0, 'purchase_order_details_id'
          3        SEND_VAL                                                 ~7
          4        DO_ICALL                                         $8      
          5        ASSIGN                                                   !1, $8
   17     6      > FE_RESET_R                                       $10     !1, ->26
          7    > > FE_FETCH_R                                               $10, !2, ->26
   18     8    >   INIT_FCALL                                               'array_intersect'
          9        FETCH_DIM_R                                      ~11     !0, 'purchase_order_details_id'
         10        SEND_VAL                                                 ~11
         11        INIT_ARRAY                                       ~12     !2
         12        SEND_VAL                                                 ~12
         13        DO_ICALL                                         $13     
         14        ASSIGN                                                   !3, $13
   19    15        INIT_FCALL                                               'array_intersect_key'
         16        FETCH_DIM_R                                      ~15     !0, 'quantity_received'
         17        SEND_VAL                                                 ~15
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $16     
         20        ASSIGN                                                   !4, $16
   20    21        INIT_ARRAY                                       ~19     !3, 'purchase_order_details_id'
         22        ADD_ARRAY_ELEMENT                                ~19     !4, 'quantity_received'
         23        ASSIGN_DIM                                               !5, !2
         24        OP_DATA                                                  ~19
   17    25      > JMP                                                      ->7
         26    >   FE_FREE                                                  $10
   22    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !5
         29        DO_ICALL                                                 
   23    30        INIT_FCALL                                               'extract'
         31        SEND_REF                                                 !5
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.96 ms | 1396 KiB | 23 Q