3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param string $date format rrrr-mm-dd * @return mixed - false or date format d.m.rrrr which really exists */ function typicalFormat($date){ $date = explode('-', $date); if(count($date) == 3){ $year = $date[0]; $date[1] = preg_replace('~^0~', '', $date[1]); $date[0] = preg_replace('~^0~', '', $date[2]); $date[2] = $year; $date = implode('.', $date); if(existsDate($date) == 1){ return $date; } return false; } return false; } /** * @param string $date format d.m.rrrr * @return bool * @copyright Jakub Vrána, http://php.vrana.cz/ */ function existsDate($date){ return preg_match('~^([1-9]|19|[12][0-8]|29(?=\\.([^2]|2\\.(([02468][048]|[13579][26])00|[0-9]{2}(0[48]|[2468][048]|[13579][26]))))|30(?=\\.[^2])|31(?=\\.([13578][02]?\\.)))\\.([1-9]|1[012])\\.[0-9]{4}$~D', $date); } var_dump(typicalFormat('2014-02-j5')); die();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/EdTsh
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'typicalformat'
          2        SEND_VAL                                                 '2014-02-j5'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > EXIT                                                     
          7*     > RETURN                                                   1

Function typicalformat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 41
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 40
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EdTsh
function name:  typicalFormat
number of ops:  43
compiled vars:  !0 = $date, !1 = $year
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '-'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ASSIGN                                                   !0, $2
   11     6        COUNT                                            ~4      !0
          7        IS_EQUAL                                                 ~4, 3
          8      > JMPZ                                                     ~5, ->41
   12     9    >   FETCH_DIM_R                                      ~6      !0, 0
         10        ASSIGN                                                   !1, ~6
   13    11        INIT_FCALL                                               'preg_replace'
         12        SEND_VAL                                                 '%7E%5E0%7E'
         13        SEND_VAL                                                 ''
         14        FETCH_DIM_R                                      ~9      !0, 1
         15        SEND_VAL                                                 ~9
         16        DO_ICALL                                         $10     
         17        ASSIGN_DIM                                               !0, 1
         18        OP_DATA                                                  $10
   14    19        INIT_FCALL                                               'preg_replace'
         20        SEND_VAL                                                 '%7E%5E0%7E'
         21        SEND_VAL                                                 ''
         22        FETCH_DIM_R                                      ~12     !0, 2
         23        SEND_VAL                                                 ~12
         24        DO_ICALL                                         $13     
         25        ASSIGN_DIM                                               !0, 0
         26        OP_DATA                                                  $13
   15    27        ASSIGN_DIM                                               !0, 2
         28        OP_DATA                                                  !1
   16    29        INIT_FCALL                                               'implode'
         30        SEND_VAL                                                 '.'
         31        SEND_VAR                                                 !0
         32        DO_ICALL                                         $15     
         33        ASSIGN                                                   !0, $15
   17    34        INIT_FCALL_BY_NAME                                       'existsDate'
         35        SEND_VAR_EX                                              !0
         36        DO_FCALL                                      0  $17     
         37        IS_EQUAL                                                 $17, 1
         38      > JMPZ                                                     ~18, ->40
   18    39    > > RETURN                                                   !0
   20    40    > > RETURN                                                   <false>
   22    41    > > RETURN                                                   <false>
   23    42*     > RETURN                                                   null

End of function typicalformat

Function existsdate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EdTsh
function name:  existsDate
number of ops:  7
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%7E%5E%28%5B1-9%5D%7C19%7C%5B12%5D%5B0-8%5D%7C29%28%3F%3D%5C.%28%5B%5E2%5D%7C2%5C.%28%28%5B02468%5D%5B048%5D%7C%5B13579%5D%5B26%5D%2900%7C%5B0-9%5D%7B2%7D%280%5B48%5D%7C%5B2468%5D%5B048%5D%7C%5B13579%5D%5B26%5D%29%29%29%29%7C30%28%3F%3D%5C.%5B%5E2%5D%29%7C31%28%3F%3D%5C.%28%5B13578%5D%5B02%5D%3F%5C.%29%29%29%5C.%28%5B1-9%5D%7C1%5B012%5D%29%5C.%5B0-9%5D%7B4%7D%24%7ED'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   32     6*     > RETURN                                                   null

End of function existsdate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.79 ms | 1394 KiB | 24 Q