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 sortByDate($a, $b) { $datetime1 = date_create($a); $datetime2 = date_create($b); $interval = date_diff($datetime1, $datetime2); $diff = $interval->format('%a'); if($diff>0){return 1;} if($diff<0){return -1;} if($diff==0){return 0;} return false; } usort($array, 'sortByDate'); var_dump($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D5Blc
function name:  (null)
number of ops:  12
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                                                 
   17     4        INIT_FCALL                                               'usort'
          5        SEND_REF                                                 !0
          6        SEND_VAL                                                 'sortByDate'
          7        DO_ICALL                                                 
   18     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function sortbydate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 22
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 28
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D5Blc
function name:  sortByDate
number of ops:  30
compiled vars:  !0 = $a, !1 = $b, !2 = $datetime1, !3 = $datetime2, !4 = $interval, !5 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL                                               'date_create'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !2, $6
    8     6        INIT_FCALL                                               'date_create'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $8      
          9        ASSIGN                                                   !3, $8
    9    10        INIT_FCALL                                               'date_diff'
         11        SEND_VAR                                                 !2
         12        SEND_VAR                                                 !3
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !4, $10
   10    15        INIT_METHOD_CALL                                         !4, 'format'
         16        SEND_VAL_EX                                              '%25a'
         17        DO_FCALL                                      0  $12     
         18        ASSIGN                                                   !5, $12
   11    19        IS_SMALLER                                               0, !5
         20      > JMPZ                                                     ~14, ->22
         21    > > RETURN                                                   1
   12    22    >   IS_SMALLER                                               !5, 0
         23      > JMPZ                                                     ~15, ->25
         24    > > RETURN                                                   -1
   13    25    >   IS_EQUAL                                                 !5, 0
         26      > JMPZ                                                     ~16, ->28
         27    > > RETURN                                                   0
   14    28    > > RETURN                                                   <false>
   15    29*     > RETURN                                                   null

End of function sortbydate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.25 ms | 1400 KiB | 21 Q