How can I get a php loop to print out:
1 1 2 2 3 3 all the way to 250 250. So basically count from 1 - 250 but print out each number twice?
How can I get a php loop to print out:
1 1 2 2 3 3 all the way to 250 250. So basically count from 1 - 250 but print out each number twice?
for ($i = 1; $i <= 250; $i++) {
echo $i; // print the first time
echo $i; // print the second time
}
You can obviously print duplicated value with one echo statement and make the code one line shorter.
for($i = 1; $i <= 250; $i++)
{
echo $i, ' ', $i, ($i != 250 ? ' ' : NULL);
}