Page 1 of 1

Preg/Search Help Please!

Posted: Sat Nov 27, 2004 1:37 pm
by zatch
I want to be able to search an input and if a certain words (i want to check for multiple words) is in the input return a variable true.

ie:

Code: Select all

<?php
if ($_POSTї'mypost'] CONTAINS "STRING1 OR STRING2") 
{ 
$ecample = "1"; 
} 
?>

Any ideas?
thanks!

Posted: Sat Nov 27, 2004 1:56 pm
by kral_majales
you could use regular expressions? they can be a bit scary at first, but they are very versatile and useful :)

K

Posted: Sat Nov 27, 2004 2:26 pm
by rehfeld
1- will the words to search for be single words, or could they be 'two words'
2- case sensitive?
3 will there be other words in $_POST['mypost'] other than what your looking for?

should it match this?

search = 'blind'
in
'i have window blinds'

Posted: Sat Nov 27, 2004 3:59 pm
by timvw
[php_man]strpos[/php_man]