Home >Backend Development >PHP Problem >How to find an integer within 100 that is divisible by 3 and has a units digit of 6 in PHP
Implementation method: 1. Use "for($i=1;$i
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
We can use the for loop to control the range. Use an if statement to find the number of symbolic conditions.
First way:
<?php for($i=1; $i<100; $i++){ if($i%3==0&&$i%10==6) echo $i, '<br>'; } ?>
Output result:
Second One way
<?php for($i=3; $i<100; $i=$i+3){ if($i%10==6) echo $i, '<br>'; } ?>
Output result:
Related introduction:
PHP (PHP: Hypertext Preprocessor) that is "Hypertext preprocessor" is a scripting language executed on the server side, especially suitable for Web development and can be embedded in HTML. PHP syntax learned the C language, absorbed the characteristics of multiple languages of Java and Perl to develop its own unique syntax, and continued to improve itself based on their strengths, such as Java's object-oriented programming. The main goal of the language was originally created to make Developers quickly write high-quality web sites. PHP supports both object-oriented and process-oriented development, and is very flexible in use.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to find an integer within 100 that is divisible by 3 and has a units digit of 6 in PHP. For more information, please follow other related articles on the PHP Chinese website!