Dependent Quadratic Loops in PHP

Notes:

PHP Nested Loops :
- If required we can place one loop inside another loop. This is called as nesting of loops.

Case 3: Dependent quadratic loop:
- if inner loop iterations depend upon the outer loop counter variable value

Syntax:
for( $i=0; $i<n; $i++)
{
for( $j=0; $j<$i; $j++)
{
sequence of statement(s);
}
}

Note:
1. If out loop counter variable value is 0 then inner loop statements get execute 0 times
2. If out loop counter variable value is 1 then inner loop statements get execute 1 times
3. If out loop counter variable value is 2 then inner loop statements get execute 2 times
4. If out loop counter variable value is 3 then inner loop statements get execute 3 times
and so on…

Ex:
for( $i=0; $i<3; $i++)
{
for( $j=0; $j< $i; $j++)
{
echo “*”;
}
echo “<br/>”;
}

Interview Questions:

1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a