PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How can I create an array of numbers easily?


If you want to create an array of consecutive numbers in PHP, then you can do it the long hand way...

<?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!



ASK A QUESTION

More arrays PHP Questions

OK I've been trying to echo out the arrays "$people and $other people" using the for-each method in alphabetical order. but when i see what this displays it does it in some other order. THIS IS THE CODE PHP Ch8 Lab

How do I find out if a value is already in an array?

How do I sort the members of an array by value?

How can I mix up the order of values in an array?

How may I keyboard replace the value of one cell of the array and the save that row to MySQL using PHP ?



Custom Search