Home > Article > Backend Development > PHP outputs the palindrome number between two numbers
This article mainly introduces the method of PHP outputting how many palindromes there are between two numbers. It analyzes the concept of palindromes and related judgment skills with examples. Friends in need can refer to this article
The example describes how PHP outputs how many palindromes there are between two numbers. The specific analysis is as follows:
"Palindrome number" is a kind 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.
<?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>'; } ?>
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
Two commonly used methods for recursively deleting folders in php
php implementation method for obtaining the date of this Monday
PHP uses recursion to generate article tree_php example
The above is the detailed content of PHP outputs the palindrome number between two numbers. For more information, please follow other related articles on the PHP Chinese website!