PHP输出两个数字中间有多少个回文数的方法_php技巧

WBOY
Release: 2016-05-16 20:19:44
Original
1021 people have browsed it

本文实例讲述了PHP输出两个数字中间有多少个回文数的方法。分享给大家供大家参考。具体分析如下:

"回文数"是一种数字。如:98789, 这个数字正读是98789,倒读也是98789,正读倒读一样,所以这个数字就是回文数。

<&#63;php
 for($i=10;$i<100;$i++){
    $len=strlen($i);
    $l=1;
    $k=intval($len)/2+1;
   for($j=0;$j<$k;$j++){
    if (substr($i,$j,1)!=substr($i,$len-$j-1,1))
     $l=0;
     break;
 }
if ($l==1)
echo $i.'<br>';
}
&#63;>
Copy after login

希望本文所述对大家的php程序设计有所帮助。

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template