Comparing not the exact of two values...

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
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Comparing not the exact of two values...

Post by JellyFish »

I'm trying to do an if statement like this:

Code: Select all

if ($_POST['search'] == $search[$l]) {
The problem I'm having is spaces in my $_POST[search] are one problem what I mean when I say this is that the I'm trying to compare it with the $search (which is the keywords of each thing that my search engine is trying to search). I don't really know how to explain what I'm trying to explain so I'm just going to ask:

How would I make $_POST[search], when comparing it to $search, not compare the spaces and both $_POST and the $search strings.

I'll think about this more but I think I explained it good. :? Thanks for reading and all help is appreciated. :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

remove the spaces? str_replace()
tmarion
Forum Newbie
Posts: 5
Joined: Sun Feb 26, 2006 3:23 am
Contact:

Post by tmarion »

trim() also works nicely, although it is just for the beginning and ending spaces.

www.marionweb.com
- Business solutions through technology.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post by JellyFish »

Yeah, this information works. I the like tirm function. It works nice and does do what I need.

Thanks for both of your post, any more posts are still exepted, if anyone has something they might want to add. :)
Post Reply