3v4l.org

run code in 300+ PHP versions simultaneously
<?php function lastWeekDay ($mnt) { $result = strtotime("last day of $mnt"); $day = date('D', $result); if ('Sun' === $day) { $result -= 86400 * 2; } if ('Sat' === $day) { $result -= 86400; } return $result; } $input = '01-04-2014'; $a = explode('-',$input); $result = strftime("%b",mktime(0,0,0,$a[0])).'-'.$a[1]; echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LFQXU
function name:  (null)
number of ops:  23
compiled vars:  !0 = $input, !1 = $a, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, '01-04-2014'
   18     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '-'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   19     6        INIT_FCALL                                               'strftime'
          7        SEND_VAL                                                 '%25b'
          8        INIT_FCALL                                               'mktime'
          9        SEND_VAL                                                 0
         10        SEND_VAL                                                 0
         11        SEND_VAL                                                 0
         12        FETCH_DIM_R                                      ~6      !1, 0
         13        SEND_VAL                                                 ~6
         14        DO_ICALL                                         $7      
         15        SEND_VAR                                                 $7
         16        DO_ICALL                                         $8      
         17        CONCAT                                           ~9      $8, '-'
         18        FETCH_DIM_R                                      ~10     !1, 1
         19        CONCAT                                           ~11     ~9, ~10
         20        ASSIGN                                                   !2, ~11
   20    21        ECHO                                                     !2
         22      > RETURN                                                   1

Function lastweekday:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
Branch analysis from position: 15
filename:       /in/LFQXU
function name:  lastWeekDay
number of ops:  20
compiled vars:  !0 = $mnt, !1 = $result, !2 = $day
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'strtotime'
          2        NOP                                                      
          3        FAST_CONCAT                                      ~3      'last+day+of+', !0
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !1, $4
    5     7        INIT_FCALL                                               'date'
          8        SEND_VAL                                                 'D'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11        ASSIGN                                                   !2, $6
    6    12        IS_IDENTICAL                                             !2, 'Sun'
         13      > JMPZ                                                     ~8, ->15
    8    14    >   ASSIGN_OP                                     2          !1, 172800
   10    15    >   IS_IDENTICAL                                             !2, 'Sat'
         16      > JMPZ                                                     ~10, ->18
   12    17    >   ASSIGN_OP                                     2          !1, 86400
   14    18    > > RETURN                                                   !1
   15    19*     > RETURN                                                   null

End of function lastweekday

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.77 ms | 1400 KiB | 23 Q