PHP: Create an array for a range
arrays, numbers, php, range, variables
Solution
This can be solved by using a simple for loop:
// Start ↓ End ↓ Step ↓
for ($i = 1; $i <= $num; ++$i) {
$array[] = $i;
}
Problem
If I have a variable `$num = 50` how can I put the numbers 1-50 into an array?