3v4l.org

run code in 300+ PHP versions simultaneously
<?php function RS_GET_CLOSEST_DATE_WITH_DAYNAME($day_name, $format = 'Y-m-d H:i:s') { $day_name = ucfirst($day_name); if(date('l', time()) == $day_name) { return date($format, time()); } else if(abs(time()-strtotime('next '.$day_name)) < abs(time()-strtotime('last '.$day_name))) { return date($format, strtotime('next '.$day_name)); } else { return date($format, strtotime('last '.$day_name)); } } echo RS_GET_CLOSEST_DATE_WITH_DAYNAME('Wednesday');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IS0ug
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'rs_get_closest_date_with_dayname'
          1        SEND_VAL                                                 'Wednesday'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function rs_get_closest_date_with_dayname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 22
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 54
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IS0ug
function name:  RS_GET_CLOSEST_DATE_WITH_DAYNAME
number of ops:  64
compiled vars:  !0 = $day_name, !1 = $format
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      'Y-m-d+H%3Ai%3As'
    4     2        INIT_FCALL                                               'ucfirst'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !0, $2
    6     6        INIT_FCALL                                               'date'
          7        SEND_VAL                                                 'l'
          8        INIT_FCALL                                               'time'
          9        DO_ICALL                                         $4      
         10        SEND_VAR                                                 $4
         11        DO_ICALL                                         $5      
         12        IS_EQUAL                                                 !0, $5
         13      > JMPZ                                                     ~6, ->22
    8    14    >   INIT_FCALL                                               'date'
         15        SEND_VAR                                                 !1
         16        INIT_FCALL                                               'time'
         17        DO_ICALL                                         $7      
         18        SEND_VAR                                                 $7
         19        DO_ICALL                                         $8      
         20      > RETURN                                                   $8
         21*       JMP                                                      ->63
   10    22    >   INIT_FCALL                                               'abs'
         23        INIT_FCALL                                               'time'
         24        DO_ICALL                                         $9      
         25        INIT_FCALL                                               'strtotime'
         26        CONCAT                                           ~10     'next+', !0
         27        SEND_VAL                                                 ~10
         28        DO_ICALL                                         $11     
         29        SUB                                              ~12     $9, $11
         30        SEND_VAL                                                 ~12
         31        DO_ICALL                                         $13     
         32        INIT_FCALL                                               'abs'
         33        INIT_FCALL                                               'time'
         34        DO_ICALL                                         $14     
         35        INIT_FCALL                                               'strtotime'
         36        CONCAT                                           ~15     'last+', !0
         37        SEND_VAL                                                 ~15
         38        DO_ICALL                                         $16     
         39        SUB                                              ~17     $14, $16
         40        SEND_VAL                                                 ~17
         41        DO_ICALL                                         $18     
         42        IS_SMALLER                                               $13, $18
         43      > JMPZ                                                     ~19, ->54
   12    44    >   INIT_FCALL                                               'date'
         45        SEND_VAR                                                 !1
         46        INIT_FCALL                                               'strtotime'
         47        CONCAT                                           ~20     'next+', !0
         48        SEND_VAL                                                 ~20
         49        DO_ICALL                                         $21     
         50        SEND_VAR                                                 $21
         51        DO_ICALL                                         $22     
         52      > RETURN                                                   $22
         53*       JMP                                                      ->63
   16    54    >   INIT_FCALL                                               'date'
         55        SEND_VAR                                                 !1
         56        INIT_FCALL                                               'strtotime'
         57        CONCAT                                           ~23     'last+', !0
         58        SEND_VAL                                                 ~23
         59        DO_ICALL                                         $24     
         60        SEND_VAR                                                 $24
         61        DO_ICALL                                         $25     
         62      > RETURN                                                   $25
   18    63*     > RETURN                                                   null

End of function rs_get_closest_date_with_dayname

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.63 ms | 1403 KiB | 24 Q