If I have a variable $num = 50
how can I put the numbers 1-50 into an array?
The array_keys() function returns an array containing the keys.
The range of an array is the difference between the maximum element of the array and the minimum element. You want to find the minimum range of the array by doing any number of operations on the array. You can do multiple operations on a single element as well.
Take a look at the range function.
$array = range(1, $num);
This can be solved by using a simple for loop:
// Start ↓ End ↓ Step ↓
for ($i = 1; $i <= $num; ++$i) {
$array[] = $i;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With