Hello everyone I made this php code
$variablename = "Marron";
$tallas = '#^/' . implode(array("XL", "L", "M", "S", "XS"), '|') . '/#';
if (preg_match($tallas, $variablename, $matchesatr)) {
$opciones = "Tallas";
} else {
$opciones = "Opciones";
}
Which results in M since it found the result M in the word Marron
You can check this in $matchesatr
The problem here is that I need my preg_match to be very exact that I just need it to only match the value "M" if there is only that word.
Currently if the value of the variable begins or contains M returns true as a result.
I need you to be very sensitive to explain myself better.
If you find the value M of as true result.
If you find a word that starts with M or contains M of false result.
Of course, I have an array of words to search for, which would be: XL, L, M, S, XS
Additional note: I also need it to be case insensitive eg to detect "M" or "m"
$tallas = '#^(?:' . implode(array("XL", "L", "M", "S", "XS"), '|') . ')$#';or$tallas = '#\b(?:' . implode(array("XL", "L", "M", "S", "XS"), '|') . ')\b#';|first