Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-06-13 10:16:15
Original
1383 people have browsed it

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

 代码如下 复制代码
  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);
?>
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!