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 = 'dd-mm-yy'; $a = explode('-',$input); $result = $a[1].'-'.$a[0].'-'.$a[2]; echo $result;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FCc4N
function name:  (null)
number of ops:  16
compiled vars:  !0 = $input, !1 = $a, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, 'dd-mm-yy'
   18     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '-'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   19     6        FETCH_DIM_R                                      ~6      !1, 1
          7        CONCAT                                           ~7      ~6, '-'
          8        FETCH_DIM_R                                      ~8      !1, 0
          9        CONCAT                                           ~9      ~7, ~8
         10        CONCAT                                           ~10     ~9, '-'
         11        FETCH_DIM_R                                      ~11     !1, 2
         12        CONCAT                                           ~12     ~10, ~11
         13        ASSIGN                                                   !2, ~12
   20    14        ECHO                                                     !2
         15      > 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/FCc4N
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:
167.33 ms | 1396 KiB | 19 Q