PHP Loops

0
2كيلو بايت

In the following chapters you will learn how to repeat code by using loops in PHP.


PHP Loops

Often when you write code, you want the same block of code to run over and over again a certain number of times. So, instead of adding several almost equal code-lines in a script, we can use loops.

Loops are used to execute the same block of code again and again, as long as a certain condition is true.

In PHP, we have the following loop types:

  • while - loops through a block of code as long as the specified condition is true
  • do...while - loops through a block of code once, and then repeats the loop as long as the specified condition is true
  • for - loops through a block of code a specified number of times
  • foreach - loops through a block of code for each element in an array

The following chapters will explain and give examples of each loop type.

البحث
الأقسام
إقرأ المزيد
أخرى
PHP Loops
In the following chapters you will learn how to repeat code by using loops in PHP. PHP Loops...
بواسطة PHP Tutorial 2024-05-17 07:48:35 0 2كيلو بايت
أخرى
PHP Delete Array Items
Remove Array Item To remove an existing item from an array, you can use...
بواسطة PHP Tutorial 2024-05-17 08:06:22 0 3كيلو بايت
أخرى
PHP if Operators
Comparison Operators If statements usually contain conditions that compare two values....
بواسطة PHP Tutorial 2024-05-17 07:45:46 0 2كيلو بايت
أخرى
PHP Numbers
In this chapter we will look in depth into Integers, Floats, and Number Strings. PHP Numbers...
بواسطة PHP Tutorial 2024-05-17 07:37:05 0 3كيلو بايت
أخرى
PHP Update Array Items
Update Array Item To update an existing array item, you can refer to the index number for...
بواسطة PHP Tutorial 2024-05-17 08:02:49 0 3كيلو بايت