3v4l.org

run code in 300+ PHP versions simultaneously
<?php $abc = array( 'rec_1' => array('f_name'=>'Aron','m_i'=>'M'), 'rec_2' => array('f_name'=>'Abbey','m_i'=>'D'), 'rec_3' => array('f_name'=>'Alice','m_i'=>'P')); echo $abc['rec_1']['f_name'], "\n"; function build_sorter($key) { return function ($a, $b) use ($key) { return strnatcmp($a[$key], $b[$key]); }; } usort($abc, build_sorter('f_name')); foreach ($abc as $item) { echo $item['f_name'] . ', ' . $item['m_i'] . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 21
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/XprpK
function name:  (null)
number of ops:  23
compiled vars:  !0 = $abc, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    7     1        FETCH_DIM_R                                      ~3      !0, 'rec_1'
          2        FETCH_DIM_R                                      ~4      ~3, 'f_name'
          3        ECHO                                                     ~4
          4        ECHO                                                     '%0A'
   15     5        INIT_FCALL                                               'usort'
          6        SEND_REF                                                 !0
          7        INIT_FCALL                                               'build_sorter'
          8        SEND_VAL                                                 'f_name'
          9        DO_FCALL                                      0  $5      
         10        SEND_VAR                                                 $5
         11        DO_ICALL                                                 
   17    12      > FE_RESET_R                                       $7      !0, ->21
         13    > > FE_FETCH_R                                               $7, !1, ->21
   18    14    >   FETCH_DIM_R                                      ~8      !1, 'f_name'
         15        CONCAT                                           ~9      ~8, '%2C+'
         16        FETCH_DIM_R                                      ~10     !1, 'm_i'
         17        CONCAT                                           ~11     ~9, ~10
         18        CONCAT                                           ~12     ~11, '%0A'
         19        ECHO                                                     ~12
   17    20      > JMP                                                      ->13
         21    >   FE_FREE                                                  $7
   19    22      > RETURN                                                   1

Function build_sorter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XprpK
function name:  build_sorter
number of ops:  5
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FXprpK%3A10%240'
          2        BIND_LEXICAL                                             ~1, !0
   12     3      > RETURN                                                   ~1
   13     4*     > RETURN                                                   null

End of function build_sorter

Function %00%7Bclosure%7D%2Fin%2FXprpK%3A10%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XprpK
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $a, !1 = $b, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   11     3        INIT_FCALL                                               'strnatcmp'
          4        FETCH_DIM_R                                      ~3      !0, !2
          5        SEND_VAL                                                 ~3
          6        FETCH_DIM_R                                      ~4      !1, !2
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                         $5      
          9      > RETURN                                                   $5
   12    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FXprpK%3A10%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.62 ms | 1403 KiB | 18 Q