MrXander Posted August 27, 2007 Share Posted August 27, 2007 Is there a way to see if a string contains a hash symbol? (#) Basically, I want to make sure when people submit data via the textfield, they don't include a hash. Quote Link to comment https://forums.phpfreaks.com/topic/66908-checking-a-string/ Share on other sites More sharing options...
Barand Posted August 27, 2007 Share Posted August 27, 2007 <?php if (strpos($string, '#') !== false) echo "# not permitted"; else { // OK // process string } ?> Quote Link to comment https://forums.phpfreaks.com/topic/66908-checking-a-string/#findComment-335449 Share on other sites More sharing options...
Fadion Posted August 27, 2007 Share Posted August 27, 2007 if(strstr($string, '#')){ echo "Got ya"; } or u can definitely remove those unwanted '#' chars: $string = 'this is some# text'; if(strstr($string, '#')){ $string = str_replace('#', '', $string); } Quote Link to comment https://forums.phpfreaks.com/topic/66908-checking-a-string/#findComment-335742 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.