shadiadiph Posted February 27, 2009 Share Posted February 27, 2009 Hi I am wondering is it possible to remove a ? using php I have a user input field which is called question where the user has to enter a question but it is hard to say if the user would type "What is my middle name" or "what is my middle name?" what I am trying to achieve is that if the user adds it I can remove the ? before storing it to the database any ideas? Link to comment https://forums.phpfreaks.com/topic/147150-how-can-i-remove-a-from-a-user-input/ Share on other sites More sharing options...
kenrbnsn Posted February 27, 2009 Share Posted February 27, 2009 Remove all "?" from a string: <?php $str = str_replace('?','',$str); ?> To remove only the last character if it's a '?' <?php if (substr($str,-1) == '?') $str = substr($str,0,-1); ?> Ken Link to comment https://forums.phpfreaks.com/topic/147150-how-can-i-remove-a-from-a-user-input/#findComment-772482 Share on other sites More sharing options...
shadiadiph Posted February 27, 2009 Author Share Posted February 27, 2009 thanks this would probably be the best one right? $question = str_replace('?','',$question); as I dont know maybe the user might put a period after the ?. Link to comment https://forums.phpfreaks.com/topic/147150-how-can-i-remove-a-from-a-user-input/#findComment-772483 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.