3v4l.org

run code in 300+ PHP versions simultaneously
<?php $filename1 = "Ruggeri, Nichole M. - 10-21-2014.pdf"; $filename2 = "[Rx] - 01-02-2003 - Walton, Charles E.pdf"; $filename3 = "9-29-2014.pdf"; function validate_date($filename) { preg_match("/(^\D*)(\d+-\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 $filename; return $date; } echo validate_date($filename1); //print_r (validate_date($filename1)); //print_r (validate_date($filename2)); //print_r (validate_date($filename3)); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tq5B5
function name:  (null)
number of ops:  8
compiled vars:  !0 = $filename1, !1 = $filename2, !2 = $filename3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Ruggeri%2C+Nichole+M.+-+10-21-2014.pdf'
    4     1        ASSIGN                                                   !1, '%5BRx%5D+-+01-02-2003+-+Walton%2C+Charles+E.pdf'
    5     2        ASSIGN                                                   !2, '9-29-2014.pdf'
   27     3        INIT_FCALL                                               'validate_date'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $6      
          6        ECHO                                                     $6
   33     7      > 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/tq5B5
function name:  validate_date
number of ops:  58
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%5E%5CD%2A%29%28%5Cd%2B-%5Cd%2B-%5Cd%2B%29%28%5CD%2A%24%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
   23    56      > RETURN                                                   !6
   24    57*     > RETURN                                                   null

End of function validate_date

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.27 ms | 1402 KiB | 24 Q