JAY BHARAT, software enginer, php programmers, software engineer, jay bharat ,9844542127

 
»
S
I
D
E
B
A
R
«
palindrome code in php
September 2nd, 2009 by admin

palindrome code in php

METHOD1:

<?php
//madam aibohphobia Malayalam
$word="Malayalam";
$word=strtoupper($word);
$len=strlen($word);
$first=substr($word,0,($len/2));
$word=strrev($word);
$second=substr($word,0,($len/2));
if($first==$second)
{
echo "Palindrome";
}
else
{
echo "Not Palindrome";
}
?>

METHOD2:

<?php
//madam aibohphobia Malayalam
$word="Malayalam";
$word=strtoupper($word);
$first=$word;
$second=strrev($word);
if($first==$second)
{
echo "Palindrome";
}
else
{
echo "Not Palindrome";
}
?>

One Response  
Arup writes:
March 8th, 2010 at 1:28 pm

This is nice one….. Very simple & nice one….. This same program can we do with out using strings library function???

Leave a Reply