Home >Backend Development >PHP Tutorial >PHP determines whether a string is a palindrome string_PHP tutorial

PHP determines whether a string is a palindrome string_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:15:34971browse

This article will introduce you to an example to determine whether a string is a palindrome string. Friends who need to know more can refer to it.

 代码如下 复制代码
function ishuiwen($str){
$len=strlen($str);
$l=1;
$k=intval($len/2)+1;
for($j=0;$j<$k;$j++){
if (substr($str,$j,1)!=substr($str,$len-$j-1,1))
{
$l=0;
break;
}


}
if ($l==1)
{
return 1;
}
else
{
return -1;
}
}

$str=12321;
echo ishuiwen($str);
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/628807.htmlTechArticleThis article will introduce you to an example to determine whether a string is a palindrome string. If you need to know more Friends can refer to it. The code is as follows Copy the code ?php function ishuiwen...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn