Reputation: 285
Currently I have a code that looks like:
for ($i=0; $i<=($num_newlines - 1); $i++)
{
$tweetcpitems->post('statuses/update',
array('status' => wordFilter("The item $parts[$i] has been released on Club Penguin. View it here: http://clubpenguincheatsnow.com/tools/swfviewer/items.swf?id=$parts[$id]")));
sleep(90);
}
What I want to do make the "i++" part add by two and not one, but how do I do this? Please help!
Upvotes: 11
Views: 24778
Reputation: 8135
For those who are looking to increment pair of numbers (like 1-2 to 3-4):
Solution one:
//initial values
$n_left = 1;
$n_right = 2;
for ($i = 1; $i <= 5; $i++) {
print "\n" . $n_left . "-" . $n_right;
$n_left =+ $n_left+2;
$n_right =+ $n_right+2;
}
//result: 1-2 3-4 5-6 7-8 9-10
Solution two:
for ($y = 0; $y <= 9; $y+=2) {
print "\n" . ($y+1) . "-" . ($y+2);
}
//result: 1-2 3-4 5-6 7-8 9-10
Upvotes: 0
Reputation: 927
$i++ : increment by one
$i+=2 : increment by two
$i+=3 : increment by three
etc..
Upvotes: 6