Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the ways to write php for loops

Shulou Source: shulou.com Published: 2022-06-02 15:52:00 10月03日 Update

This article mainly explains "what are the ways to write the php for cycle". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what are the ways to write the php for cycle?"

Php for loop can be written in two ways: 1, "for (expr1; expr2; expr3) {...}"; 2, "for (expr1; expr2; expr3) {if (...) {} break;}." The way.

How many ways to write a php for loop?

Writing and examples of PHP for loops

For loop is one of the most recent loop statements, no matter what language, there is this loop statement, and it is also a common loop method in our work.

Grammar rules:

For (expr1; expr2; expr3) {Code to be executed}

Expr1: indicates where the loop begins

Expr2: the condition of the loop. If the value is TRUE, the loop continues and the nested loop statement is executed. If the value is FALSE, the loop is terminated.

Expr3: evaluated (and executed) after each loop.

The writing is a little obscure, let's write the simplest for loop demo!

For Loop demo1:

Tags: Loop statement writing result content just way method time condition learning output practical deeper obscure code interest place practicality reality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Redmi Apple MariaDB Shulou Tech Info