MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

For Loop and Nested For Loop in PHP.

For Loop

The for loop is frequently used, when a loop is to run for a fixed number of time.

Syntax

for (initialization; test-condition; increment/decrement)
{
block of statements;
}

Sample program

Output

Browser output of the PHP for loop printing Loop Count 1 to 4

Nested For Loop

When a statement block of a for-loop lies completely inside the block of a new for-loop then, it is called Nested for loop.

Syntax

Nested for loop syntax diagram with the inner for loop inside the outer for loop block

Sample Program

Output

Nested for loop output: inner loop counts 1 to 3 for each of outer loop counts 1 and 2

Break and Continue Statement.

Break Statement is used to stop any loop or switch Statement at any time.

Sample Program

Output

Break statement output in browser showing Loop Count 1 to 3 before the loop stops

Continue Statement

This statement is used to skip the repetition of a loop.

Sample Program

Output

Continue statement output showing Loop Count 1 to 10 with 5 skipped

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals

Related Posts

Encryption using RSA public and Private Key using PHP

PHP's OpenSSL extension can create an RSA key pair, encrypt data with the public key and decrypt it with the private key. This page explains the gist…

Read More

Encryption using Public key and Private key in PHP using mySql database

This tutorial shows how to generate an RSA key pair with PHP's OpenSSL extension, encrypt form input with the public key, store the ciphertext in MySQL, and…

Read More

How to see number of emails sent using smtp in laravel

Laravel does not count or log SMTP emails by default, so a grep will only return a real number once your application writes one log line for…

Read More

What are the Authentication type in phpmyadmin which for config.inc.php

phpMyAdmin supports four authentication types, set per server with $cfg['Servers'][$i]['auth_type'] in config.inc.php: cookie (the default), config, http and signon. This page explains how each one works and…

Read More

What is opcache and Install / Configure in Linux

OPcache is PHP's built-in bytecode cache. It keeps compiled scripts in shared memory so PHP doesn't have to parse and compile the same files on every request….

Read More

PHP Code for Godaddy VPS Server SMTP Email Relay

This page shows how to send email from a GoDaddy VPS through GoDaddy's SMTP relay on port 25 with plain PHP sockets and no extra libraries. Below…

Read More