gevo12321 Posted September 5, 2008 Share Posted September 5, 2008 ok lets say i get a sentence through $_post and i want to see if a certain character apperas in the sentence. how would i do it? Quote Link to comment https://forums.phpfreaks.com/topic/122946-solved-finding-a-certain-character-in-a-sentence/ Share on other sites More sharing options...
fanfavorite Posted September 5, 2008 Share Posted September 5, 2008 check out http://ca.php.net/strpos Quote Link to comment https://forums.phpfreaks.com/topic/122946-solved-finding-a-certain-character-in-a-sentence/#findComment-634949 Share on other sites More sharing options...
gevo12321 Posted September 5, 2008 Author Share Posted September 5, 2008 one more thing, im doing this for a contact page to make sure that the email address thy give is a valid one and has the @ char in it. i was wondering if it would be better if i did it browserside in javascript rather than serverside in php Quote Link to comment https://forums.phpfreaks.com/topic/122946-solved-finding-a-certain-character-in-a-sentence/#findComment-634951 Share on other sites More sharing options...
elis Posted September 5, 2008 Share Posted September 5, 2008 Try this: if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) {echo "this email is invalid"; }) Checks for both the presence of an @ sign, a period, and that no odd characters are present in the email. Replace "$email" for whatever the variable for the email input is. Quote Link to comment https://forums.phpfreaks.com/topic/122946-solved-finding-a-certain-character-in-a-sentence/#findComment-634960 Share on other sites More sharing options...
gevo12321 Posted September 5, 2008 Author Share Posted September 5, 2008 thank you Quote Link to comment https://forums.phpfreaks.com/topic/122946-solved-finding-a-certain-character-in-a-sentence/#findComment-634968 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.