I have some data that I am putting in a database but I need it modified as it gets inserted. I have several entries that have two digit years in parentheses. They come in the following formats: (98) OR (87-92) I basically want to rewrite them like this: (1998) OR (1987-1992) And I also need to check for the condition of a number between 00 and 11 because that would then constitue appending 20 to the beginning rather than 19. Can anyone help me get started with this?
try this: <?php $pattern = array('/\b[23456789]\d\b/', '/\b0\d\b/', '/\b[1][0123456789]\b/'); $replace = array( '19$0', '20$0', '20$0'); $subject = array('94', '11', '03-10', '55', '70-84', '12', '19', '07-14'); var_dump((preg_filter($pattern, $replace, $subject))); ?> PHP: