I have a problem, I have this code:
$chelp = str_word_count($add, 0); //Get the number of words
$chelp2 = $chelp -1; //Get the last word
$chelp3 = $chelp -2; //Get the second to last word
$cit = str_word_count($add, 1);
$cfull = "" . $cit[$chelp3] . " " . $cit[$chelp2] . ""; //Put the words together
foreach ($twowords as $val)
{
if ($cfull == $val)
{
$area = $val;
}
else
{
}
}
Basically, $twowords is an array, like so:
"Word One"
"Word Two"
So, what this is meant to do, is look for the two last words, and if it equals a $twowords word (like Word One or Word Two), it will set $area to that.
It seems to work, but when I echo outside of the foreach, it equals nothing, even if a word was found.
Can anyone help?