English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

A person on Y!Answers said I needed to do this, but I don't know what he's talking about or how to do it... can someone give me examples?

2007-02-26 08:39:59 · 2 answers · asked by Am 4 in Computers & Internet Programming & Design

2 answers

A counter is just a variable you create to "keep a count" of something. For example, how many times you run a loop.

If your counter variable is "counter", you can increment it by one by doing the following:

counter = counter + 1;
or:
counter += 1;
or:
counter++;

All do the same thing.

An example using a counter "i":

for ($i = 1; $i <= 10; $i++) {
print "$i
";
}

2007-02-26 08:55:19 · answer #1 · answered by javier 2 · 2 1

this how you increment using for and while loops

for($i=0; $i<10; $i++){
echo $i;
}

//while loop
$i=0;
while($i<20){
$i++;
}

2007-02-26 16:51:05 · answer #2 · answered by Mohamed 3 · 1 0

fedest.com, questions and answers