3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( array( 'nome' => 'Alexandre', 'idade' => '65' ), array( 'nome' => 'Alex', 'idade' => '33' ), array( 'nome' => 'Zezinha', 'idade' => '29' ), array( 'nome' => 'Rosana', 'idade' => '64' ) ); function Ordena_Array ($array, $campo) { // Compara se $a é maior que $b $callback = function ($a, $b) use ($campo) { return $a[$campo] > $b[$campo]; }; // Ordena usort($array, $callback); return $array; } // Mostra os valores print_r( Ordena_Array ($array, "nome") );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMtYS
function name:  (null)
number of ops:  9
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'ordena_array'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'nome'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function ordena_array:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMtYS
function name:  Ordena_Array
number of ops:  11
compiled vars:  !0 = $array, !1 = $campo, !2 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          3        BIND_LEXICAL                                             ~3, !1
          4        ASSIGN                                                   !2, ~3
   17     5        INIT_FCALL                                               'usort'
          6        SEND_REF                                                 !0
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                                 
   19     9      > RETURN                                                   !0
   20    10*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oMtYS
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $a, !1 = $b, !2 = $campo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   13     3        FETCH_DIM_R                                      ~3      !0, !2
          4        FETCH_DIM_R                                      ~4      !1, !2
          5        IS_SMALLER                                       ~5      ~4, ~3
          6      > RETURN                                                   ~5
   14     7*     > RETURN                                                   null

End of Dynamic Function 0

End of function ordena_array

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.79 ms | 1449 KiB | 16 Q