3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( "artists" => array( "1" => array( "id" => "1", "firstname" => "John", "lastname" => "Doe", "songs" => array( array("name" => "song_1", "year" => "1999"), array("name" => "song_2", "year" => "1987") ), ), "2" => array( "id" => "2", "firstname" => "Jane", "lastname" => "Doe", "songs" => array( array("name" => "song_1", "year" => "2000"), array("name" => "song_2", "year" => "1999") ) ), "3" => array( "id" => "3", "firstname" => "Mark", "lastname" => "Doe", "songs" => array( array("name" => "song_1", "year" => "1984"), array("name" => "song_2", "year" => "1983") ) ) ) ); array_walk($arr['artists'], function (&$song) { usort($song['songs'], function ($a, $b) { return $a['year'] > $b['year'] ? 1 : -1; }); // Ascending order //usort($song['songs'], function ($a, $b) { return $a['year'] < $b['year'] ? 1 : -1; }); // Descending order }); print('<pre>'); print_r($arr); print('</pre>');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M8Vs8
function name:  (null)
number of ops:  13
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   35     1        INIT_FCALL                                               'array_walk'
          2        FETCH_DIM_W                                      $2      !0, 'artists'
          3        SEND_REF                                                 $2
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FM8Vs8%3A35%240'
   38     5        SEND_VAL                                                 ~3
          6        DO_ICALL                                                 
   40     7        ECHO                                                     '%3Cpre%3E'
   41     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
   42    11        ECHO                                                     '%3C%2Fpre%3E'
         12      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FM8Vs8%3A35%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M8Vs8
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $song
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
   36     1        INIT_FCALL                                               'usort'
          2        FETCH_DIM_W                                      $1      !0, 'songs'
          3        SEND_REF                                                 $1
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FM8Vs8%3A36%241'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                                 
   38     7      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FM8Vs8%3A35%240

Function %00%7Bclosure%7D%2Fin%2FM8Vs8%3A36%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/M8Vs8
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !0, 'year'
          3        FETCH_DIM_R                                      ~3      !1, 'year'
          4        IS_SMALLER                                               ~3, ~2
          5      > JMPZ                                                     ~4, ->8
          6    >   QM_ASSIGN                                        ~5      1
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      -1
          9    > > RETURN                                                   ~5
         10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FM8Vs8%3A36%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.45 ms | 1400 KiB | 19 Q