Reputation: 323
range($low, $high, $step)
Create an array containing a range of elements
I would like to put my range as 1 - 12 but than add another option for 99. Can i do this by creating a variable and than passing the variable into the array?
<?php $infin = range(1,12,99); ?>
I'm not really sure how to accomplish this but it seems easy and i'm kind of drawing blanks right now.
Upvotes: 0
Views: 62
Reputation: 28906
$infin = range(1, 12);
$infin[] = 99;
The second line allows you to add a new element to the end of an array.
Output:
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
[9] => 10
[10] => 11
[11] => 12
[12] => 99
)
Upvotes: 5