I do not understand the question well, but if the idea is to have 1 to 10, or from 1 to 100, or from 50 to 200, always based on numbers and incrementing then you can simply use range()
of PHP itself , example:
$foo = range(1, 10);
print_r($foo);
Then you can use with foreach
or even implode
, examples:
foreach
foreach (range(1, 10) as $contador) {
echo "O contador agora é: {$contador}.";
}
implode
$foo = range(1, 10);
$baz = 'O contador agora é: ';
echo $baz . implode('. ' . $baz, $foo) . '.';
About the range
The range()
function of PHP does not generate only numerical array, for example if you do something like:
range('a', 'e');
This will generate an array like this:
array('a', 'b', 'c', 'd', 'e');
And you can do the reverse as well:
range('z', 'a');
This will generate an array like this:
array('a', 'b', 'c', 'd', 'e');
That will generate an array like this:
Array
(
[0] => z
[1] => y
[2] => x
[3] => w
[4] => v
[5] => u
[6] => t
[7] => s
[8] => r
[9] => q
[10] => p
)
That is, range
works for numbers and letters and you can reverse the order.