Is there any simpler way to write the following code? It will be much bigger than 2 cases, so it will be difficult to handle soon.
if ($result == 'yes')
{
echo 'this text';
}
else if ($result == 'no')
{
$result = in_string($kairos_array, explode(' ', $input_string));
if ($result == 'yes')
{
echo 'that text';
}
}
You probably can reorganise your code - create a function and just use return
when you've found what you need. This way the nesting won't increase and the code will be easy to read.
if ($result == 'yes')
{
return 'this text';
}
$result = in_string($kairos_array, explode(' ', $input_string));
if ($result == 'yes')
{
return 'that text';
}
(note, I've removed check for $result == 'no'
as it's not needed at all if the value can be only 'yes' or 'no')