PHP for Loop

A for loop is very similar to a while loop as it continues to process a block of code until a statement becomes false, however everything is defined in a single line.

Syntax: for ( start; conditional; increment) { code to execute; }

Example


<?php
$output = '<ul>';
for ($test = 5; $test <= 50; $test += 5){
	$output .= '<li>'.$test.'</li>';
}
$output .= '</ul>';

echo $output;
?>

PHP foreach Loop

foreach loop works only on arrays, and is used to loop through each key/value pair in an array.

Syntax: foreach ($array as $value){ code to be executed; }

In foreach loop, the value of the current array element is assigned to $value and the array pointer is moved by one, until it reaches the last array value.

Example


<?php
$names = array("Bryan","Petter","John");

foreach ($names as $name){
  echo $name . '<br>';
}
?>

How to take Cialis it seems to me that would already be time to cease to discuss this question. As I already answered it not once. Have it in a look. You shouldn’t worry! All deer go south when they are called by homesickness. Are turned and lie on snow till some hours.