Various Looping in PHP


Various Looping in PHP

PHP is a programming language used to process data on a website application. Every dynamic website must use PHP because this php functions to process all data from the database and display it to the website it manages. As for displaying data from the database, what is used to display it is by looping or looping using php.


There are several types of loops in php, including WHILE, DO-WHILE, FOR, and FOREACH. The following are examples and explanations of the loops mentioned above.

1. WHILE

The way to use WHILE is like the following.



And the results are like the following.


2. DO-WHILE

the way to use DO-WHILE is similar to WHILE looping, the difference here is using DO. How to use it is as follows.



And the results are as follows.


3. FOR

Repetition using FOR is also almost the same as WHILE. The difference is just the placement of the conditions. The following is an example of its use.



And the results are as follows.


4. FOREACH

Repetition using FOREACH is used to loop values from an array. The forms of use are as follows.



And the results are as follows.



Thus a short tutorial on various types of loops in PHP. Please study carefully so that the knowledge is more helpful and useful. If there are those who don't understand, you can ask through comments. So for the discussion this time, if there is a wrong word I apologize. thanks.

Belum ada Komentar untuk "Various Looping in PHP"

Posting Komentar

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel