3v4l.org

run code in 500+ PHP versions simultaneously
<?php $myarray = array( 0 => array( "Order" => array("PO" => "TR11214", "OrderID" => 242856952012), "Sales Tax" => array("PO" => "TR11214", "SalesTaxAmount" => 0.00), "Payment" => array("PaymentPO" => "TR11215", "PaymentAmount" => 45.00), "Transaction" => array("TransPO" => "TR11211", "TransactionPrice" => 91.17) ), 1 => array( "Order" => array("PO" => "TR11214", "OrderID" => 242856952012), "Sales Tax" => array("PO" => "TR11214", "SalesTaxAmount" => 0.00), "Payment" => array("PaymentPO" => "TR11216", "PaymentAmount" => 70.00), "Transaction" => array("TransPO" => "TR11212", "TransactionPrice" => 180.41) ), 2 => array( "Order" => array("PO" => "TR11214", "OrderID" => 242856952012), "Sales Tax" => array("PO" => "TR11214", "SalesTaxAmount" => 0.00), "Payment" => array("PaymentPO" => "TR11216", "PaymentAmount" => 70.00), "Transaction" => array("TransPO" => "TR11213", "TransactionPrice" => 209.99) ) ); echo "there are " . count(array_unique(array_column($myarray, 'Order'), SORT_REGULAR)) . "unique Orders\n"; $non_unique_keys = ['Transaction', 'Payment']; $output = array(); foreach (array_keys($myarray[0]) as $key) { if (in_array($key, $non_unique_keys)) { $output[$key] = array_unique(array_column($myarray, $key), SORT_REGULAR); } else { $output[$key] = $myarray[0][$key]; } } print_r($output);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 39
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 39
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 34
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/otmid
function name:  (null)
number of ops:  44
compiled vars:  !0 = $myarray, !1 = $non_unique_keys, !2 = $output, !3 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   22     1        INIT_FCALL                                                   'array_unique'
          2        INIT_FCALL                                                   'array_column'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     'Order'
          5        DO_ICALL                                             $5      
          6        SEND_VAR                                                     $5
          7        SEND_VAL                                                     0
          8        DO_ICALL                                             $6      
          9        COUNT                                                ~7      $6
         10        CONCAT                                               ~8      'there+are+', ~7
         11        CONCAT                                               ~9      ~8, 'unique+Orders%0A'
         12        ECHO                                                         ~9
   24    13        ASSIGN                                                       !1, <array>
   25    14        ASSIGN                                                       !2, <array>
   26    15        INIT_FCALL                                                   'array_keys'
         16        FETCH_DIM_R                                          ~12     !0, 0
         17        SEND_VAL                                                     ~12
         18        DO_ICALL                                             $13     
         19      > FE_RESET_R                                           $14     $13, ->39
         20    > > FE_FETCH_R                                                   $14, !3, ->39
   27    21    >   FRAMELESS_ICALL_2                in_array            ~15     !3, !1
         22      > JMPZ                                                         ~15, ->34
   28    23    >   INIT_FCALL                                                   'array_unique'
         24        INIT_FCALL                                                   'array_column'
         25        SEND_VAR                                                     !0
         26        SEND_VAR                                                     !3
         27        DO_ICALL                                             $17     
         28        SEND_VAR                                                     $17
         29        SEND_VAL                                                     0
         30        DO_ICALL                                             $18     
         31        ASSIGN_DIM                                                   !2, !3
         32        OP_DATA                                                      $18
   27    33      > JMP                                                          ->38
   31    34    >   FETCH_DIM_R                                          ~20     !0, 0
         35        FETCH_DIM_R                                          ~21     ~20, !3
         36        ASSIGN_DIM                                                   !2, !3
         37        OP_DATA                                                      ~21
   26    38    > > JMP                                                          ->20
         39    >   FE_FREE                                                      $14
   34    40        INIT_FCALL                                                   'print_r'
         41        SEND_VAR                                                     !2
         42        DO_ICALL                                                     
         43      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
210.11 ms | 2273 KiB | 17 Q