3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(array('date'=>'2014-12-01', 'price'=>'123.00'), array('date'=>'2013-12-01', 'price'=>'123.00'), array('date'=>'2014-02-01', 'price'=>'123.00'), array('date'=>'2014-03-01', 'price'=>'123.00')); var_dump($array); function date_compare($a, $b) { $t1 = strtotime($a['date']); $t2 = strtotime($b['date']); return $t1 - $t2; } usort($array, 'date_compare'); var_dump($array); function dateCompare($a, $b) { $t1 = strtotime($a); $t2 = strtotime($b); return round(($t1 - $t2)/86400); } var_dump(dateCompare(date(), '2014-03-06'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S82G2
function name:  (null)
number of ops:  21
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   12     4        INIT_FCALL                                               'usort'
          5        SEND_REF                                                 !0
          6        SEND_VAL                                                 'date_compare'
          7        DO_ICALL                                                 
   14     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
   22    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               'datecompare'
         13        INIT_FCALL                                               'date'
         14        DO_ICALL                                         $5      
         15        SEND_VAR                                                 $5
         16        SEND_VAL                                                 '2014-03-06'
         17        DO_FCALL                                      0  $6      
         18        SEND_VAR                                                 $6
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function date_compare:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S82G2
function name:  date_compare
number of ops:  15
compiled vars:  !0 = $a, !1 = $b, !2 = $t1, !3 = $t2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        INIT_FCALL                                               'strtotime'
          3        FETCH_DIM_R                                      ~4      !0, 'date'
          4        SEND_VAL                                                 ~4
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
    9     7        INIT_FCALL                                               'strtotime'
          8        FETCH_DIM_R                                      ~7      !1, 'date'
          9        SEND_VAL                                                 ~7
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !3, $8
   10    12        SUB                                              ~10     !2, !3
         13      > RETURN                                                   ~10
   11    14*     > RETURN                                                   null

End of function date_compare

Function datecompare:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/S82G2
function name:  dateCompare
number of ops:  17
compiled vars:  !0 = $a, !1 = $b, !2 = $t1, !3 = $t2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   18     2        INIT_FCALL                                               'strtotime'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !2, $4
   19     6        INIT_FCALL                                               'strtotime'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !3, $6
   20    10        INIT_FCALL                                               'round'
         11        SUB                                              ~8      !2, !3
         12        DIV                                              ~9      ~8, 86400
         13        SEND_VAL                                                 ~9
         14        DO_ICALL                                         $10     
         15      > RETURN                                                   $10
   21    16*     > RETURN                                                   null

End of function datecompare

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.78 ms | 1403 KiB | 24 Q