3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 65 => [ ["p" => 234, "sp" => 234], ["p" => 53, "sp" => 5], ["p" => 530, "sp" => 5], ] ]; $col = 'p'; // set the column you want to order on $column = array_column($arr[65], $col); array_multisort($column, SORT_ASC, $arr[65]); // SORT_ASC or SORT_DESC $arr[65] = $arr[65][0]; // only keep the record with lowest 'p' value var_dump($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fYTrS
function name:  (null)
number of ops:  22
compiled vars:  !0 = $arr, !1 = $col, !2 = $column
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, 'p'
   12     2        INIT_FCALL                                               'array_column'
          3        FETCH_DIM_R                                      ~5      !0, 65
          4        SEND_VAL                                                 ~5
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !2, $6
   13     8        INIT_FCALL                                               'array_multisort'
          9        SEND_REF                                                 !2
         10        SEND_VAL                                                 4
         11        FETCH_DIM_W                                      $8      !0, 65
         12        SEND_REF                                                 $8
         13        DO_ICALL                                                 
   14    14        FETCH_DIM_R                                      ~11     !0, 65
         15        FETCH_DIM_R                                      ~12     ~11, 0
         16        ASSIGN_DIM                                               !0, 65
         17        OP_DATA                                                  ~12
   17    18        INIT_FCALL                                               'var_dump'
         19        SEND_VAR                                                 !0
         20        DO_ICALL                                                 
         21      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.97 ms | 1012 KiB | 16 Q