3v4l.org

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

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

End of function build_sorter

Function %00%7Bclosure%7D%2Fin%2FFdE9S%3A9%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FdE9S
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $a, !1 = $b, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   10     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
   11    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FFdE9S%3A9%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154 ms | 1403 KiB | 20 Q