PHP Program to Check a String is Palindrome or Not Using for Loop

PHP Program to Check a String is Palindrome or Not Using for Loop

  • PHP
  • 1 min read

Here is a PHP program to check a string is a palindrome or not using for loop.

<html>
<body>
<?php 
$count=0;
$a="madam";
for($i=0;$i<strlen($a);$i=$i+1)
{
if($a{$i}==$a{strlen($a)-$i-1})
{
$count=$count+1;
}
}
if($count==strlen($a))
echo "The string is a palindrome";
else
echo "The string is not a palindrome";


?>
</body>
</html>

Output: The string is a palindrome

See also: