3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Get an array of human readable times for sun events * @param \DateTime $date A \DateTime Object set to the desired date * and the correct timezone for the place in question * @param float $lat The latitude of the place in question * @param float $lon The longitude of the place in question * * @return array An associative array of human readable times sorted in chronological order. */ function adjustedSunInfo(\DateTime $date,$lat,$lon) { $sinfo=date_sun_info ($date->getTimestamp() ,$lat,$lon ); foreach($sinfo as $key=>$val) { //You should check that the value isn't 1 or empty first $time = new \DateTime('@' . $val); $time->setTimezone($date->getTimeZone()); $sinfo[$key] = $time->format('Y m d H:i:s'); } asort($sinfo); return $sinfo; } $time = new \DateTime('2013-01-01', new \DateTimeZone('Pacific/Chatham')); var_dump(adjustedSunInfo($time, -44.5, -176.2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hnZH3
function name:  (null)
number of ops:  17
compiled vars:  !0 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'DateTime'
          1        SEND_VAL_EX                                              '2013-01-01'
          2        NEW                                              $2      'DateTimeZone'
          3        SEND_VAL_EX                                              'Pacific%2FChatham'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $2
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $1
   26     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'adjustedsuninfo'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 -44.5
         12        SEND_VAL                                                 -176.2
         13        DO_FCALL                                      0  $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function adjustedsuninfo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 30
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 30
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/hnZH3
function name:  adjustedSunInfo
number of ops:  36
compiled vars:  !0 = $date, !1 = $lat, !2 = $lon, !3 = $sinfo, !4 = $val, !5 = $key, !6 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   12     3        INIT_FCALL                                               'date_sun_info'
          4        INIT_METHOD_CALL                                         !0, 'getTimestamp'
          5        DO_FCALL                                      0  $7      
          6        SEND_VAR                                                 $7
          7        SEND_VAR                                                 !1
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !3, $8
   14    11      > FE_RESET_R                                       $10     !3, ->30
         12    > > FE_FETCH_R                                       ~11     $10, !4, ->30
         13    >   ASSIGN                                                   !5, ~11
   16    14        NEW                                              $13     'DateTime'
         15        CONCAT                                           ~14     '%40', !4
         16        SEND_VAL_EX                                              ~14
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !6, $13
   17    19        INIT_METHOD_CALL                                         !6, 'setTimezone'
         20        INIT_METHOD_CALL                                         !0, 'getTimeZone'
         21        DO_FCALL                                      0  $17     
         22        SEND_VAR_NO_REF_EX                                       $17
         23        DO_FCALL                                      0          
   18    24        INIT_METHOD_CALL                                         !6, 'format'
         25        SEND_VAL_EX                                              'Y+m+d+H%3Ai%3As'
         26        DO_FCALL                                      0  $20     
         27        ASSIGN_DIM                                               !3, !5
         28        OP_DATA                                                  $20
   14    29      > JMP                                                      ->12
         30    >   FE_FREE                                                  $10
   21    31        INIT_FCALL                                               'asort'
         32        SEND_REF                                                 !3
         33        DO_ICALL                                                 
   22    34      > RETURN                                                   !3
   23    35*     > RETURN                                                   null

End of function adjustedsuninfo

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.62 ms | 1413 KiB | 20 Q