Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Sep 032010
 

Create an array containing a range of elements in PHP

Answer:

It is easy to create an array using the range() function, e.g.

<?php

foreach (range(0, 10) as $number) {
        echo $number, " ";
}

It shows following when executed:

0 1 2 3 4 5 6 7 8 9 10

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>