Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A perfect palindrome is a word or phrase that is identical forward or backward,

ID: 3709784 • Letter: A

Question

A perfect palindrome is a word or phrase that is identical forward or backward, such as the word “racecar”, “mom”, or “dad”. An example of a standard palindrome is “Madam, I’m Adam” because the characters are identical forwards or backwards, provided you remove the spaces, and punctuation marks. Write a script that checks whether a word entered by a user is a palindrome. To check for a standard palindrome use a function to remove the punctuation marks (comma, apostrophe, period, and exclamation point) and a function to remove the extra spaces. Use an HTML document containing a form with a single textbox to enter the string text and a single script to display and process the form. DO NOT USE preg_replace to remove characters. No credit will be received if this function is used. PLEASE DO NOT USE PREG_REPLACE MUST BE IN PHP FORM

Explanation / Answer

<html>
<body>
<h3>Palindrome</h3>
<form action="" method="post">
<label>Enter a String <label>
<input type="text" name="string" />
<input type="submit" value="Submit" />
</form>
</body>
</html>

palindrome.php :

<?php

  
if($_POST){

$string = $_POST['string'];
  
$string = str_replace(' ', '', $string);
  
$string = preg_replace('/[^A-Za-z0-9-]/', '', $string);

$string = strtolower($string);
  
$reverse = strrev($string);
  
if($string == $reverse){
echo "<p>It is a Palindrome</p>";
}else{
echo "</p>It is Not a Palindrome</p>";
}
  
}

?>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote