<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Untitled Document</title>
</head>
<body>
<?php
//$people = array("h","e","l","l","o");
//$result = sizeof($people);
//for($i=0;$i<=$result;$i--)
//{echo($people);}
if ($_REQUEST['btnsubmit'] !="")
{
$txtword = $_REQUEST['txtword'];
$str= $txtword;
$str1=" ";
$ctr=0;
//To find the String Length
while($str[$ctr])
{
$ctr++;
}
$i=$ctr;
echo $i;
//Storing it reversely in second array
for($j=0;$j<$ctr;$j++){
$str1[$j] = $str[$i-1];
$i--;
}
//Check For Palindrome
if($str==$str1)
$pal="The String is a palindrome";
else
$pal= "The String is Not a Palindrome";
//Display values
echo "The Given String is ".$str."<br/><br/> The Reversed String is ".$str1."<br/<br/>";
echo "<br/>".$pal;
}
?>
<form action="" name="frm" method="post">
<table border="1">
<tr>
<td>
Enter a text:
</td>
<td>
<input type="text" name="txtword" value="" />
</td>
</tr>
<tr>
<td>
<input type="submit" name="btnsubmit" value="SUBMIT" />
</td>
</tr>
</table>
</form>
</body>
</html>