Forum Moderators: coopster

Message Too Old, No Replies

Doing if statements based on part of a string

         

ro1960

8:13 am on May 23, 2008 (gmt 0)

10+ Year Member



I am trying to do a bunch of if and elseif based on part of a variable.

All the variables I want to process in the same manner contain the same string:

submit_#*$!
submit_yyy
submit_zzz etc..

So I would like to do something like this:

if ($_GET['var'] OPERATOR "submit_") {....

Does such an operator exists? Or do I have to do use a "==" for each variable I want to process? I guess what I am looking for is an operator that means "contain".

Thanks for any help.

barns101

8:44 am on May 23, 2008 (gmt 0)

10+ Year Member



You can use strpos() [php.net] to find out whether a variable contains a particular string.