There are $wordCounter instances of $sw on this site
";
}
function output($inputArray, $sw)
{
global $wordCounter;
$return = "";
foreach($inputArray as $input)
{
if(strpos(strtolower($input), $sw) !== false) $wordCounter++;
$return .= "Facts About \"$input\"
";
$return .= "";
$return .= "- Palindrome: ".(isPalindrome($input) ? "TRUE" : "FALSE")."
";
$return .= "- Number of Characters: ".strlen($input)."
";
$return .= "- Number of Words: ".str_word_count($input)."
";
$return .= "
";
}
return $return;
}
function isPalindrome($phrase)
{
//removes spaces from phrase
$phrase = str_replace(" ", "", $phrase);
$phrase = str_replace("'", "", $phrase);
$phrase = str_replace("?", "", $phrase);
$phrase = str_replace("/", "", $phrase);
$phrase = str_replace("\\", "", $phrase);
$phrase = str_replace(".", "", $phrase);
$phrase = str_replace(",", "", $phrase);
//lower case the phrase
$phrase = strtolower($phrase);
//reverse phrase and assign to variable
$revPhrase = strrev($phrase);
//compare and return
if($revPhrase == $phrase) return true;
else return false;
}
if(!empty($_POST['search-word']) && !empty($_POST['pal-count']))
{
$searchWord = $_POST['search-word'];
$palCount = $_POST['pal-count'];
}
else header('location: .?error=true');
if (!isset($_POST['palindromes']))
{
$displayPageContent .= '';
}
else
{
$inputs = $_POST['palindromes'];
$displayPageContent .= output($inputs, $searchWord);
$displayPageContent .= wordCountOutput($searchWord);
}
?>
Palindrome Stuff