Dhara Parmar Dhara Parmar - 4 months ago 11
PHP Question

How to create dynamically array of 1 to 100 with gap of 10 values in php

Can some one tell me how can I create

array
of number dynamically without any
for
loop.

ex. I want to create array like:

[0] => 10
[1] => 20
[2] => 30
[3] => 40
..
[9] => 100

Answer

You could use range(). The third argument is the number to step between values when interpolating between the start and ending values.

$numbers = range(10, 100, 10);