How can I create an array of numbers easily?
<?php
$myarray = array(1,2,3,4,5,6,7);
?>
Or you can do it the easy way, using the range function, which you simply pass the first and last value in the consecutive range. So this is equivalent to the above code:
<?php
$myarray = range(1,7);
?>
... and when you want an array containing the numbers 1 to a 1,000 - then you'll be glad you learned about this function!
Comment on this Question and Answer >>>
ASK A QUESTION
More arrays PHP Questions
i need to store a multi-dimensioned array into a file. there is plenty of info. on creating md-arrays but i cant find anything on writing a md-array to a file.How can I reverse sort an array keeping the correlation between the index and value?
How do I remove and view the last element of an array?
How do I find if a value is already in an array or not?
How can I sort an array keeping the correlation between the index and value?
