Jump to content

[SOLVED] Similar value in if command?


djfox

Recommended Posts

I know how to do greater than, less than, and equal to with if ()

But what about something like "if $wt[2] can be found in the string of values entered in $pa[2]"?

 

Example:

Let`s say $pa[2] is "Normal"

And let`s say $wt[2] is "Normal,Ice,Rock,Steel"

 

How could I get if () to look for $pa[2] in $wt[2] ?

Link to comment
Share on other sites

for that... you may use one of the following:

 

strstr() or stristr() : if you are looking for the first occurrence of the string. the second one is case insensitive.

 

strpos() or stripos() or strrpos() : same with the section above but will only return the position... faster if your only concern is if the word string exist.

 

but if you want to check the whole string for any occurence, then use preg_match() preg_replace() if you want to replace all the matching strings found with a different string.

 

cheers,

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.