mcarterbrown.com
Palmer Pursuit
 

Plugged In Online Gaming, and Technology

Reply
 
LinkBack Thread Tools
Old 05-09-2007, 09:58 AM   #1 (permalink)
I Am The Admin
 
Painthappy's Avatar
 
Join Date: Mar 2006
Location: New Boston, NH
Send a message via AIM to Painthappy
I need a PHP if expression on finding a string...

OK... I'm trying to find a few letters in a word.

Example: $word = myword

Now lets say I want to find "ord" in that string or word

In perl is use:

if ($word =~ "ord") { blah... }

if PHP is use???

I know it's ereg (or I think it is) in PHP, but I can't seem to make it work.

if (ereg('[ord]',$word)) { blah... }

Any php masters around here?
__________________
Focal point of a distant gaze

MCB Rules - Please Read them
MySpace.com/painthappy - MySpace Blog

PM me or Email me if you have tips, paintball news, or press releases.
Painthappy is online now   Reply With Quote
Old 05-09-2007, 10:20 AM   #2 (permalink)
Seasoned Member
 
thrive78's Avatar
 
Join Date: Apr 2006
Location: Va
Send a message via AIM to thrive78
strpos() should be simple enough for you. *edit...didn't mean it like that. I meant approach......

PHP: strpos - Manual
__________________
Blazer #2454
POG #1062
POG Feedback MCB Feedback
thrive78 is offline   Reply With Quote
Old 05-09-2007, 10:22 AM   #3 (permalink)
MCB Member
 
DarkStar's Avatar
 
Join Date: Mar 2006
I think you just need to drop the brackets from your code.

"[ab]": matches a string that has either an a or a b (that's the same as "a|b");


-MR
__________________
FeedBack

Quote:
Originally Posted by Marauder_Pilot View Post
It will eventually get to the point where you're living in the back of a '78 Oldsmobile with a trunk full of the finest paintball gear known to man.
DarkStar is offline   Reply With Quote
Old 05-09-2007, 10:25 AM   #4 (permalink)
I Am The Admin
 
Painthappy's Avatar
 
Join Date: Mar 2006
Location: New Boston, NH
Send a message via AIM to Painthappy
Hey DarkStar... Thanks... That was all I needed. Just dropped the [] and it worked.

Excellent.


Carter
__________________
Focal point of a distant gaze

MCB Rules - Please Read them
MySpace.com/painthappy - MySpace Blog

PM me or Email me if you have tips, paintball news, or press releases.
Painthappy is online now   Reply With Quote
Old 05-09-2007, 10:38 AM   #5 (permalink)
MCB Member
 
DarkStar's Avatar
 
Join Date: Mar 2006
Cool

Might as well be doing some code this morning. God knows I don't feel like doing my own

-MR
__________________
FeedBack

Quote:
Originally Posted by Marauder_Pilot View Post
It will eventually get to the point where you're living in the back of a '78 Oldsmobile with a trunk full of the finest paintball gear known to man.
DarkStar is offline   Reply With Quote
Reply

  mcarterbrown.com » General » Plugged In

Thread Tools

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Censor is Off
Forum Jump



All times are GMT -4. The time now is 11:01 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0