3v4l.org

run code in 500+ 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); // get all p values asort($column); // sort values ascending but keep keys $arr[65] = $arr[65][array_key_first($column)]; // replace key "65" array by array-value with key containing lowest "p" var_dump($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lhUpL
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                                                   'asort'
          9        SEND_REF                                                     !2
         10        DO_ICALL                                                     
   14    11        INIT_FCALL                                                   'array_key_first'
         12        SEND_VAR                                                     !2
         13        DO_ICALL                                             $11     
         14        FETCH_DIM_R                                          ~10     !0, 65
         15        FETCH_DIM_R                                          ~12     ~10, $11
         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.5.0


preferences:
161.93 ms | 2002 KiB | 17 Q