replace preg_replace with php url functions and in_array for parsing file type extensions