Читать книгу PHP Programming for Beginners. Key Programming Concepts. How to use PHP with MySQL and Oracle databases (MySqli, PDO) - Sergey D Skudaev - Страница 14

The while Loop

Оглавление

The ‘while loop’ is used in many programming languages. A code inside a while loop is executed while a condition is true.

When using the while loop, make sure that your condition will become false and the loop stops. Otherwise you will be continuously stuck in the loop.

Let us print our array using the while loop.


while ($i <$asize) {


print (“Hello, ".name [$i].”<br />”;


$i ++;


}


Output:

Hello, John!

Hello, George!

Hello, James!

Hello, Anna!

Hello, Robert!

Hello, John!

Hello, James!

Hello, George!

Hello, Maria!

Hello, Peter!

Hello, James!

PHP Programming for Beginners. Key Programming Concepts. How to use PHP with MySQL and Oracle databases (MySqli, PDO)

Подняться наверх