Reputation: 285
I have a problem, first off, I have a variable $num_newlines that changes to the amount of lines a files has. Then what I want to do is duplicate a line to one less than what $num_newlines equals. The line is:
$tweetcpitems->post('statuses/update', array('status' => wordFilter("The item $array[1] has been released on Club Penguin.")));
What I want to do next is that for each duplicate line I want the array number to change, for example:
$tweetcpitems->post('statuses/update', array('status' => wordFilter("The item *$array[1]* has been released on Club Penguin.")));
Then the second line to be like:
$tweetcpitems->post('statuses/update', array('status' => wordFilter("The item *$array[2]* has been released on Club Penguin.")));
Then the third line to have $array[3] and so on. The main problem is that I don't want to have to manually add the lines of code and change the numbers because the variable $num_newlines is always changing. Any help would be HIGHLY appreciated as I've kept on researching on how to do this, but found nothing.
Upvotes: 0
Views: 102
Reputation: 5853
use a for loop
for($i=1,$i<=$lines,$i++)
{
// ............'status' => wordFilter("The item $array[$i] has been released on Club Penguin.")));
}
Upvotes: 2
Reputation: 13257
for ($i=0; $i<($numlines - 1); $i++) {
$tweetcpitems->post('statuses/update', array('status' => wordFilter("The item $array[$i] has been released on Club Penguin.")));
}
Upvotes: 4