How can this be done with regex?
return ( $s=='aa' || $s=='bb' || $s=='cc' || $s=='dd' ) ? 1 : 0;
I'm trying to:
$s = 'aa'; $result = preg_match( '/(aa|bb|cc|dd)/', $s ); echo $result;
but obviously this returns 1 if $s contains one or more of the specified strings (not when it is equal to one of them).
source share