Reputation: 184
I there a way to compare some string in php with this kind of syntax
STRINGS == %STRING%
I only want to know if someone know a way to do it like this
Upvotes: 0
Views: 64
Reputation: 13331
If you only want to know if a string is a substring of another string you could use the strpos function in PHP: http://se.php.net/manual/en/function.strpos.php
For more generally uses, regular expressions is the way to go: http://se.php.net/manual/en/function.preg-match.php and http://www.regularexpressions.info
Upvotes: 0
Reputation: 1575
You mean, you want to match part of a string? You can use preg_match and regular expressions for that.
if(preg_match("/string/", $myString)) { /* do something */ }
Upvotes: 1
Reputation: 99495
I'm going to take a leap and assume you mean SQL syntax for 'LIKE'.
For that, you use: http://www.php.net/manual/en/function.strpos.php
Upvotes: 4