Home > Article > Backend Development > How to output how many palindromes there are between two numbers in PHP_PHP Tutorial
This article mainly introduces the method of outputting the number of palindromes in the middle of two numbers in PHP. Examples analyze the concept of palindrome numbers and related judgment skills. Friends in need can refer to it
The example in this article describes how PHP outputs how many palindromes there are between two numbers. Share it with everyone for your reference. The specific analysis is as follows:
"Palindrome" is a type of number. For example: 98789, this number is read as 98789 upright, and it is also 98789 when read backwards. It is the same when read upright and backward, so this number is a palindrome number.
?
3 4 513 14
|
<๐>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.' '; } ?> |