Home > Backend Development > PHP Tutorial > PHP outputs the palindrome number between two numbers

PHP outputs the palindrome number between two numbers

墨辰丷
Release: 2023-03-31 17:54:01
Original
2360 people have browsed it

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.&#39;<br>&#39;;
}
?>
Copy after login

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!

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