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. 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 } ?> 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); } Link to comment https://forums.phpfreaks.com/topic/66908-checking-a-string/#findComment-335742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.