3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Assume that this is the data that we get back from get_users or a similar function $users = array( 0 => array( 'name' => 'Tom', 'payments' => array( 0 => array( 'date' => '2020-04-15', 'amount' => '750', ), 1 => array( 'date' => '2020-04-20', 'amount' => '900', ), ), ), 1 => array( 'name' => 'Dick', 'payments' => array( 0 => array( 'date' => '2020-04-10', 'amount' => '750', ), 1 => array( 'date' => '2020-04-15', 'amount' => '900', ), 2 => array( 'date' => '2020-04-25', 'amount' => '1250', ), ), ), 2 => array( 'name' => 'Harry', 'payments' => array( 0 => array( 'date' => '2020-04-24', 'amount' => '750', ), ), ), ); function sort_users_by_date( $user1, $user2 ) { $date1 = end($user1['payments'])['date']; $date2 = end($user2['payments'])['date']; return strtotime($date2) - strtotime($date1); } usort($users, 'sort_users_by_date'); var_dump($users);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6tVsj
function name:  (null)
number of ops:  9
compiled vars:  !0 = $users
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   52     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'sort_users_by_date'
          4        DO_ICALL                                                 
   54     5        INIT_FCALL                                               'var_dump'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function sort_users_by_date:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6tVsj
function name:  sort_users_by_date
number of ops:  23
compiled vars:  !0 = $user1, !1 = $user2, !2 = $date1, !3 = $date2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   46     2        INIT_FCALL                                               'end'
          3        FETCH_DIM_W                                      $4      !0, 'payments'
          4        SEND_REF                                                 $4
          5        DO_ICALL                                         $5      
          6        FETCH_DIM_R                                      ~6      $5, 'date'
          7        ASSIGN                                                   !2, ~6
   47     8        INIT_FCALL                                               'end'
          9        FETCH_DIM_W                                      $8      !1, 'payments'
         10        SEND_REF                                                 $8
         11        DO_ICALL                                         $9      
         12        FETCH_DIM_R                                      ~10     $9, 'date'
         13        ASSIGN                                                   !3, ~10
   49    14        INIT_FCALL                                               'strtotime'
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                         $12     
         17        INIT_FCALL                                               'strtotime'
         18        SEND_VAR                                                 !2
         19        DO_ICALL                                         $13     
         20        SUB                                              ~14     $12, $13
         21      > RETURN                                                   ~14
   50    22*     > RETURN                                                   null

End of function sort_users_by_date

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.41 ms | 1388 KiB | 21 Q