Reputation: 8705
I have a string which contains some of the following characters (comma is used as OR):
$car = (=, !=, <, <=. >, =>)
"string $car secondpart"
How can I see which character is used, adn take it in the new variable?
Upvotes: 1
Views: 90
Reputation: 3552
Use this Simple pattern:
preg_match("/!=|<=|=>|>|<|=)"/, $string, $matches)
Demo: https://regex101.com/r/bA3bG0/1
Upvotes: 0
Reputation: 784998
You can use this regex:
if (preg_match('/([!<]=|=>?|[<>])/', $car, $m))
echo $m[1];
$m[1]
will contain one of those string you're looking for.
Upvotes: 2