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.' '; } ?> |