So i have these two strings:
$title = 'Chair Material Suede Black';
$title = 'Chair Material Suede Red';
This is a snippet from my PHP function:
elseif (stripos($title, 'Suede') !== false) {
if (stripos($title, 'Red') !== false) {
return 'Red Suede Chair';
}
else {return "TEMP_Category";}
}
The function continues, and 50 lines down there is this code:
elseif (stripos($title, 'Suede') !== false) {
if (stripos($title, 'Black') !== false) {
return 'Black Suede Chair';
}
else {return "TEMP_Category";}
}
However, the string 'Chair Material Suede Black' ALWAYS returns 'TEMP_Category', because the search for 'Red' and 'Suede' is done prior to the Black one.
Is there any way to let it pass to the 'black' search?
Combine the two checks:
And move the else with TEMP_Category to the end of the checks.