3v4l.org

run code in 300+ PHP versions simultaneously
<?php $filename1 = "[Study] - Walton, Charles E 01-02-2012.txt"; $filename2 = "[Rx] - 01-02-2003 - Walton, Charles E.pdf"; function validate_date($filename) { preg_match("/(.*)(\d+-\d+-\d+)(.*)/",trim($filename),$matches); $date_arr = explode("-",$matches[2]); $month = str_pad($matches[0], 2, '0', STR_PAD_LEFT); $day = str_pad($matches[1], 2, '0', STR_PAD_LEFT); $year = $matches[2]; if ($year < 100) { if ($year > date("Y")+10) $year = $year + 1900; else $year = $year + 2000; } $date = $month . "-" . $day . "-" . $year; $filename = $matches[1] . $date . $matches[3]; return $matches[1]; } echo validate_date($filename1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dt8Js
function name:  (null)
number of ops:  7
compiled vars:  !0 = $filename1, !1 = $filename2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5BStudy%5D+-+Walton%2C+Charles+E+01-02-2012.txt'
    5     1        ASSIGN                                                   !1, '%5BRx%5D+-+01-02-2003+-+Walton%2C+Charles+E.pdf'
   26     2        INIT_FCALL                                               'validate_date'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $4      
          5        ECHO                                                     $4
          6      > RETURN                                                   1

Function validate_date:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 46
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 44
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
filename:       /in/dt8Js
function name:  validate_date
number of ops:  59
compiled vars:  !0 = $filename, !1 = $matches, !2 = $date_arr, !3 = $month, !4 = $day, !5 = $year, !6 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%28.%2A%29%28%5Cd%2B-%5Cd%2B-%5Cd%2B%29%28.%2A%29%2F'
          3        INIT_FCALL                                               'trim'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $7      
          6        SEND_VAR                                                 $7
          7        SEND_REF                                                 !1
          8        DO_ICALL                                                 
   10     9        INIT_FCALL                                               'explode'
         10        SEND_VAL                                                 '-'
         11        FETCH_DIM_R                                      ~9      !1, 2
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !2, $10
   11    15        INIT_FCALL                                               'str_pad'
         16        FETCH_DIM_R                                      ~12     !1, 0
         17        SEND_VAL                                                 ~12
         18        SEND_VAL                                                 2
         19        SEND_VAL                                                 '0'
         20        SEND_VAL                                                 0
         21        DO_ICALL                                         $13     
         22        ASSIGN                                                   !3, $13
   12    23        INIT_FCALL                                               'str_pad'
         24        FETCH_DIM_R                                      ~15     !1, 1
         25        SEND_VAL                                                 ~15
         26        SEND_VAL                                                 2
         27        SEND_VAL                                                 '0'
         28        SEND_VAL                                                 0
         29        DO_ICALL                                         $16     
         30        ASSIGN                                                   !4, $16
   13    31        FETCH_DIM_R                                      ~18     !1, 2
         32        ASSIGN                                                   !5, ~18
   14    33        IS_SMALLER                                               !5, 100
         34      > JMPZ                                                     ~20, ->46
   16    35    >   INIT_FCALL                                               'date'
         36        SEND_VAL                                                 'Y'
         37        DO_ICALL                                         $21     
         38        ADD                                              ~22     $21, 10
         39        IS_SMALLER                                               ~22, !5
         40      > JMPZ                                                     ~23, ->44
         41    >   ADD                                              ~24     !5, 1900
         42        ASSIGN                                                   !5, ~24
         43      > JMP                                                      ->46
   17    44    >   ADD                                              ~26     !5, 2000
         45        ASSIGN                                                   !5, ~26
   19    46    >   CONCAT                                           ~28     !3, '-'
         47        CONCAT                                           ~29     ~28, !4
         48        CONCAT                                           ~30     ~29, '-'
         49        CONCAT                                           ~31     ~30, !5
         50        ASSIGN                                                   !6, ~31
   20    51        FETCH_DIM_R                                      ~33     !1, 1
         52        CONCAT                                           ~34     ~33, !6
         53        FETCH_DIM_R                                      ~35     !1, 3
         54        CONCAT                                           ~36     ~34, ~35
         55        ASSIGN                                                   !0, ~36
   22    56        FETCH_DIM_R                                      ~38     !1, 1
         57      > RETURN                                                   ~38
   23    58*     > RETURN                                                   null

End of function validate_date

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.72 ms | 1402 KiB | 24 Q