Let me start by saying, this may sound silly.
I am trying to find the last occurrence of a character which is displayed multiple times throughout a string. Specifically in a file name. I am using str_replace to remove all bad file name characters from the string, however, it also removes the period before the file extension.
I am trying to bring that period back using magic -- or PHP. 😉
$bad_chars = array(" ", ".", ",", ";", ":", "`", "#", "$", "/", "|", "&");
$user_file = str_replace($bad_chars, "_", $HTTP_POST_FILES['userfile']);
Not sure where to go from here. I could use another instance of str_replace(), however I cannot give a parameter as to where it should start looking for "."
strrpos() won't help me here either. Any suggestions?