3v4l.org

run code in 300+ PHP versions simultaneously
<?php $list = array( '2016-01-29' => array( array( 'date' => 'January 29', 'time' => '8:30 am', 'datetime' => '2016-01-29T08:30:00-06:00', 'alldayflag' => 0 ), array( 'date' => 'January 29', 'time' => '12:00 am', 'datetime' => '2016-01-29T00:00:00-06:00', 'alldayflag' => 1 ), array( 'date' => 'January 29', 'time' => '2:00 pm', 'datetime' => '2016-01-29T14:00:00-06:00', 'alldayflag' => 0 ), array( 'date' => 'January 29', 'time' => '10:00 am', 'datetime' => '2016-01-29T10:00:00-06:00', 'alldayflag' => 0 ), array( 'date' => 'January 29', 'time' => '10:00 am', 'datetime' => '2016-01-29T10:00:00-06:00', 'alldayflag' => 1 ), array( 'date' => 'January 29', 'time' => '12:00 pm', 'datetime' => '2016-01-29T12:00:00-06:00', 'alldayflag' => 0 ), ), '2016-01-30' => array( array( 'date' => 'January 30', 'time' => '4:00 pm', 'datetime' => '2016-01-30T16:00:00-06:00', 'alldayflag' => 0 ), array( 'date' => 'January 30', 'time' => '5:00 pm', 'datetime' => '2016-01-30T17:00:00-06:00', 'alldayflag' => 1 ), array( 'date' => 'January 30', 'time' => '5:00 pm', 'datetime' => '2016-01-30T17:00:00-06:00', 'alldayflag' => 0 ), array( 'date' => 'January 30', 'time' => '11:00 am', 'datetime' => '2016-01-30T11:00:00-06:00', 'alldayflag' => 0 ), ) ); function sortCriteria($a, $b) { $aDateTime = new DateTime($a['datetime']); $bDateTime = new DateTime($b['datetime']); if ($aDateTime == $bDateTime) { return ($a['alldayflag'] > $b['alldayflag']) ? -1 : 1; } return ($aDateTime < $bDateTime) ? -1 : 1; } $getBeginDate = '2016-01-29'; $getEndDate = '2016-01-31'; $getCurrentDate = $getBeginDate; while(strtotime($getCurrentDate) < strtotime($getEndDate)) { usort($list[$getCurrentDate], 'sortCriteria'); $getCurrentDate = date('Y-m-d', strtotime($getCurrentDate . " +1 day")); } print_r($list);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 5
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 5
Branch analysis from position: 27
Branch analysis from position: 5
filename:       /in/DpoEm
function name:  (null)
number of ops:  31
compiled vars:  !0 = $list, !1 = $getBeginDate, !2 = $getEndDate, !3 = $getCurrentDate
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   81     1        ASSIGN                                                   !1, '2016-01-29'
   82     2        ASSIGN                                                   !2, '2016-01-31'
   83     3        ASSIGN                                                   !3, !1
   85     4      > JMP                                                      ->19
   86     5    >   INIT_FCALL                                               'usort'
          6        FETCH_DIM_W                                      $8      !0, !3
          7        SEND_REF                                                 $8
          8        SEND_VAL                                                 'sortCriteria'
          9        DO_ICALL                                                 
   87    10        INIT_FCALL                                               'date'
         11        SEND_VAL                                                 'Y-m-d'
         12        INIT_FCALL                                               'strtotime'
         13        CONCAT                                           ~10     !3, '+%2B1+day'
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                         $11     
         16        SEND_VAR                                                 $11
         17        DO_ICALL                                         $12     
         18        ASSIGN                                                   !3, $12
   85    19    >   INIT_FCALL                                               'strtotime'
         20        SEND_VAR                                                 !3
         21        DO_ICALL                                         $14     
         22        INIT_FCALL                                               'strtotime'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $15     
         25        IS_SMALLER                                               $14, $15
         26      > JMPNZ                                                    ~16, ->5
   90    27    >   INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Function sortcriteria:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 24
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DpoEm
function name:  sortCriteria
number of ops:  31
compiled vars:  !0 = $a, !1 = $b, !2 = $aDateTime, !3 = $bDateTime
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   71     2        NEW                                              $4      'DateTime'
          3        CHECK_FUNC_ARG                                           
          4        FETCH_DIM_FUNC_ARG                               $5      !0, 'datetime'
          5        SEND_FUNC_ARG                                            $5
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !2, $4
   72     8        NEW                                              $8      'DateTime'
          9        CHECK_FUNC_ARG                                           
         10        FETCH_DIM_FUNC_ARG                               $9      !1, 'datetime'
         11        SEND_FUNC_ARG                                            $9
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !3, $8
   74    14        IS_EQUAL                                                 !2, !3
         15      > JMPZ                                                     ~12, ->24
   75    16    >   FETCH_DIM_R                                      ~13     !0, 'alldayflag'
         17        FETCH_DIM_R                                      ~14     !1, 'alldayflag'
         18        IS_SMALLER                                               ~14, ~13
         19      > JMPZ                                                     ~15, ->22
         20    >   QM_ASSIGN                                        ~16     -1
         21      > JMP                                                      ->23
         22    >   QM_ASSIGN                                        ~16     1
         23    > > RETURN                                                   ~16
   78    24    >   IS_SMALLER                                               !2, !3
         25      > JMPZ                                                     ~17, ->28
         26    >   QM_ASSIGN                                        ~18     -1
         27      > JMP                                                      ->29
         28    >   QM_ASSIGN                                        ~18     1
         29    > > RETURN                                                   ~18
   79    30*     > RETURN                                                   null

End of function sortcriteria

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
128.95 ms | 1405 KiB | 21 Q