Preg/Search Help Please!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zatch
Forum Newbie
Posts: 18
Joined: Fri Jul 02, 2004 7:05 pm

Preg/Search Help Please!

Post 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!
kral_majales
Forum Commoner
Posts: 36
Joined: Wed Nov 24, 2004 2:47 pm
Location: Dorset, UK

Post by kral_majales »

you could use regular expressions? they can be a bit scary at first, but they are very versatile and useful :)

K
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post 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'
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

[php_man]strpos[/php_man]
Post Reply