tags:

views:

62

answers:

2

I know this doesn't work but is there any way of autogenerating values? It can be pretty tedious to put so many values in specially if it's 50 or maybe 100 numbers...

Here's the code so you get my idea:

for ($num = 1; $num <= 20; $num++){
    $arr = array($num);
    echo $arr[2];
};

Solved: It was the range() and arrayfill(). :)

A: 

Are you talking about the rand() function? That surely exist ;)

PHP Rand Function

+3  A: 

Take a look at the range() function.

>> $a = range(1, 10);
array (
  0 => 1,
  1 => 2,
  2 => 3,
  3 => 4,
  4 => 5,
  5 => 6,
  6 => 7,
  7 => 8,
  8 => 9,
  9 => 10,
)
>>

Or maybe array_fill()?

Ionuț G. Stan
This was it! Thank you very much!
Tek