3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'id' => 2, 'type' => 'comment', 'text' => 'hey', 'datetime' => '2010-05-15 11:29:45' ], [ 'id' => 3, 'type' => 'status', 'text' => 'oi', 'datetime' => '2010-05-26 15:59:53' ], [ 'id' => 4, 'type' => 'status', 'text' => 'yeww', 'datetime' => '2010-05-26 16:04:24' ] ]; // usort() by date column DESC: usort($array, function($a, $b) { return $b['datetime'] <=> $a['datetime']; }); echo var_export($array, true) . "\n***\n"; // usort() by date column ASC: usort($array, function($a, $b) { return $a['datetime'] <=> $b['datetime']; }); echo var_export($array, true) . "\n***\n"; // usort() by date column ASC in >= PHP7.4: //usort($array, fn($a, $b) => $a['datetime'] <=> $b['datetime']); // array_multisort() by date column DESC: array_multisort(array_column($array, 'datetime'), SORT_DESC, $array); echo var_export($array, true) . "\n***\n"; // array_multisort() by date column ASC: array_multisort(array_column($array, 'datetime'), $array); echo var_export($array, true) . "\n***\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sVeJ0
function name:  (null)
number of ops:  53
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   25     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                                 
   26     6        INIT_FCALL                                               'var_export'
          7        SEND_VAR                                                 !0
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $4      
         10        CONCAT                                           ~5      $4, '%0A%2A%2A%2A%0A'
         11        ECHO                                                     ~5
   29    12        INIT_FCALL                                               'usort'
         13        SEND_REF                                                 !0
         14        DECLARE_LAMBDA_FUNCTION                          ~6      [1]
         15        SEND_VAL                                                 ~6
         16        DO_ICALL                                                 
   30    17        INIT_FCALL                                               'var_export'
         18        SEND_VAR                                                 !0
         19        SEND_VAL                                                 <true>
         20        DO_ICALL                                         $8      
         21        CONCAT                                           ~9      $8, '%0A%2A%2A%2A%0A'
         22        ECHO                                                     ~9
   36    23        INIT_FCALL                                               'array_multisort'
         24        INIT_FCALL                                               'array_column'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 'datetime'
         27        DO_ICALL                                         $10     
         28        SEND_VAL                                                 $10
         29        SEND_VAL                                                 3
         30        SEND_REF                                                 !0
         31        DO_ICALL                                                 
   37    32        INIT_FCALL                                               'var_export'
         33        SEND_VAR                                                 !0
         34        SEND_VAL                                                 <true>
         35        DO_ICALL                                         $12     
         36        CONCAT                                           ~13     $12, '%0A%2A%2A%2A%0A'
         37        ECHO                                                     ~13
   40    38        INIT_FCALL                                               'array_multisort'
         39        INIT_FCALL                                               'array_column'
         40        SEND_VAR                                                 !0
         41        SEND_VAL                                                 'datetime'
         42        DO_ICALL                                         $14     
         43        SEND_VAL                                                 $14
         44        SEND_REF                                                 !0
         45        DO_ICALL                                                 
   41    46        INIT_FCALL                                               'var_export'
         47        SEND_VAR                                                 !0
         48        SEND_VAL                                                 <true>
         49        DO_ICALL                                         $16     
         50        CONCAT                                           ~17     $16, '%0A%2A%2A%2A%0A'
         51        ECHO                                                     ~17
         52      > RETURN                                                   1


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

End of Dynamic Function 0

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

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.03 ms | 1445 KiB | 17 Q