I have a form where someone would enter "xbrand tv" for a real example, lets say, "sony tv" I am then passing the data to the next page using the post method.
I'm using in_array to direct the results correctly. The way the code is set up below, if someone entered 'sony television' it would display the else statement.
$product_add = $_POST['syd'];
$pa = strtolower($product_add);
$tv= array('sony tv', 'vizio tv', 'panasonic tv', 'lg tv', 'samsung tv', 'phillips tv', 'sharp tv', 'dynex tv', 'toshiba tv');
if (in_array($pa, $tv))
{
//do stuff
}
else {
// do something else
}
Obviously I can add 'sony television' to the array but I feel like there has to be a more efficient way to do it.
I would like to have my $tv array look like this:
$tv= array('sony', 'vizio', 'panasonic', 'lg', 'samsung', 'phillips', 'sharp', 'dynex', 'toshiba');
and make it so if "sony tv" or "sony television" were entered in the initial form, it would be true to the initial if statement. Is that possible? If so, how should I go about it?