PHP Arrays
Initializing an Array to a Range of Integers
Problem
Solution
Use range($start, $stop):$cards = range(1, 52);
Discussion
For increments other than 1, pass an increment to range() as a third argument.So for odd numbers:
$odd = range(1, 52, 2);
And for even numbers:
$even = range(2, 52, 2);
No comments:
Post a Comment