PHP

 Home  Computers & Internet  Web Programming PHP
What is PHP?
Echo
Comments
Variables
Constants
Data Types
number_format()
Character Strings
Mathematical Operators
Comparison Operators
Logical Operators
Joining Strings
explode()
implode()
strtolower()
strtoupper()
strlen()
ucfirst()
ucwords()
strrev()
str_replace()
str_repeat()
trim()
strip_tags()
addslashes()
stripslashes()
strpos()
strrpos()
nl2br()
isset()
unset()
empty()
POST
GET
If Statements
If Else Statements
Elseif Statements
Switch Statements
For Loops
While Loops
Do While Loops
Foreach Loops
File Create
File Open
File Read
File Write
File Delete
fgets()
file_get_contents()
Date & Time
$_SERVER
Sessions
Cookies
Arrays

HOW TO USE for LOOPS IN PHP

A for loop is used to repeatedly execute a block of code. It can be set to repeat a certain amount of times or until a certain condition is met.

The general format is as follows:

for (startValue; endCondition; increment)

{

code to be executed;

}

Example:

We want to echo the numbers from 1 to 5.

for ($i=1; $i <= 5; $i++)

{

echo $i."<br>";

}

This for loop sets up a variable $i and gives it a value of 1 to start. We then set the condition part of the for loop to say that the loop must stop as soon as $i is less than or equal to 5. The $i++ increments the value of $i by 1 each time the loop runs. So $i changes in value from 1 to 2 to 3 to 4 and lastly to 5 after which the loop ends. The echo statement echos the possible $i values as the loop ran. So, therefore the above code will output:

1
2
3
4
5

Home | Privacy Policy | Terms Of Use | Contact Us | Work At Home | Online Jobs | Smart Info | Online Jobs | Data Entry Jobs | Paid Surveys | Info | Info | Typing Jobs | Article Archive | Forum Posting Jobs