How to exclude some words from the input for searching

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
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

How to exclude some words from the input for searching

Post by Calimero »

If for Ex. user inputs this in a single textfield:

auto moto cars service rooler

What is the code in PHP to exclude (for Ex. rooler) some word.

Thanks Ahead!
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Code: Select all

$exclude = array(
  'foo', 'bar', 'flibble'
);
$search = str_replace($exclude, '', $search);
Post Reply