Home  >  Article  >  php教程  >  PHP判断一个字符串是否是回文字符串

PHP判断一个字符串是否是回文字符串

WBOY
WBOYOriginal
2016-06-13 10:16:151298browse

本文章给大家介绍一个实例,用来判断字符串是不是为回文字符串,有需要了解的朋友可参考参考。

 代码如下 复制代码
  function ishuiwen($str){
   $len=strlen($str);
   $l=1;
   $k=intval($len/2)+1;
     for($j=0;$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);
?>
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