3v4l.org

run code in 300+ PHP versions simultaneously
<?php $today = date('Y-m-d'); $arr = array( [ 'id' => '1', 'date' => '2020-03-27', 'date_end' => '2020-05-02 17:00', 'date_res' => '2020-06-02' ], [ 'id' => '2', 'date' => '2020-04-27', 'date_end' => '2020-06-02 17:00', 'date_res' => '2020-08-02' ], [ 'id' => '3', 'date' => '2020-06-27', 'date_end' => '2020-07-02 17:00', 'date_res' => '2020-08-02' ], [ 'id' => '4', 'date' => '2021-01-01', 'date_end' => '2021-02-01 17:00', 'date_res' => '2021-03-01' ], [ 'id' => '5', 'date' => '2021-02-01', 'date_end' => '2021-03-01 17:00', 'date_res' => '2021-04-01' ], [ 'id' => '6', 'date' => '2021-05-01', 'date_end' => '2021-06-01 17:00', 'date_res' => '2021-08-01' ], [ 'id' => '7', 'date' => '2021-02-06', 'date_end' => '2021-01-29 17:00', 'date_res' => '2021-01-29' ], [ 'id' => '9', 'date' => '2021-04-27', 'date_end' => '2021-05-03 17:00', 'date_res' => '2021-05-03' ], [ 'id' => '10', 'date' => '2021-02-01', 'date_end' => '2021-02-06 17:00', 'date_res' => '2021-05-03' ], [ 'id' => '11', 'date' => '2021-02-02', 'date_end' => '2021-02-07 17:00', 'date_res' => '2021-05-05' ], [ 'id' => '12', 'date' => '2021-03-27', 'date_end' => '2021-02-07 17:00', 'date_res' => '2021-06-02' ]); usort($arr, function($dateA, $dateB) use ($today) { return abs(strtotime($dateA['date_res']) - strtotime($today)) - abs(strtotime($dateB['date_res']) - strtotime($today)); }); var_dump($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8Z1k2
function name:  (null)
number of ops:  15
compiled vars:  !0 = $today, !1 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'date'
          1        SEND_VAL                                                 'Y-m-d'
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
    4     4        ASSIGN                                                   !1, <array>
   72     5        INIT_FCALL                                               'usort'
          6        SEND_REF                                                 !1
          7        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          8        BIND_LEXICAL                                             ~5, !0
   76     9        SEND_VAL                                                 ~5
   72    10        DO_ICALL                                                 
   78    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > 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/8Z1k2
function name:  {closure}
number of ops:  28
compiled vars:  !0 = $dateA, !1 = $dateB, !2 = $today
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   72     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   74     3        INIT_FCALL                                               'abs'
          4        INIT_FCALL                                               'strtotime'
          5        FETCH_DIM_R                                      ~3      !0, 'date_res'
          6        SEND_VAL                                                 ~3
          7        DO_ICALL                                         $4      
          8        INIT_FCALL                                               'strtotime'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $5      
         11        SUB                                              ~6      $4, $5
         12        SEND_VAL                                                 ~6
         13        DO_ICALL                                         $7      
   75    14        INIT_FCALL                                               'abs'
         15        INIT_FCALL                                               'strtotime'
         16        FETCH_DIM_R                                      ~8      !1, 'date_res'
         17        SEND_VAL                                                 ~8
         18        DO_ICALL                                         $9      
         19        INIT_FCALL                                               'strtotime'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $10     
         22        SUB                                              ~11     $9, $10
         23        SEND_VAL                                                 ~11
         24        DO_ICALL                                         $12     
         25        SUB                                              ~13     $7, $12
         26      > RETURN                                                   ~13
   76    27*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.23 ms | 1014 KiB | 18 Q