djfox Posted June 10, 2008 Share Posted June 10, 2008 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] ? Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted June 10, 2008 Share Posted June 10, 2008 You probably want to look at the strstr() function. You could also create an array out of the string and use in_array() <?php $pa[2] = 'Normal'; $wt[2] = 'Normal,Ice,Rock,Steel'; if (in_array($pa[2], explode(',',$wt[2])) { // // do something // } ?> Ken Quote Link to comment Share on other sites More sharing options...
bluejay002 Posted June 10, 2008 Share Posted June 10, 2008 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, Quote Link to comment Share on other sites More sharing options...
djfox Posted June 10, 2008 Author Share Posted June 10, 2008 Ok, thanks for the suggestions, guys. ^^ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.