Jump to content

check string for multiple values


adibranch

Recommended Posts

Hi all, i've got a string ($currentcatid) which contains one number which changes dependant on which page the visitor is on.. ie  it may be perhaps "23" or "17" .

 

I need to do a check against this string to see if it contains any of the following values .. 31,32, 1, 24 . I cant remember how i did it before but i think it was with pipes..

 

something along the lines of

if ($currentcatid =="31"||"32"||"1"||"24") { action }

 

can anyone help?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/230081-check-string-for-multiple-values/
Share on other sites

what is the problem with the code you have? if you want to check whether the string contains this number, you will have to use a function like strstr (http://php.net/manual/en/function.strstr.php), because currently you are checking whether the variable has exactly this value

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.