To create an array of a series of consecutive numbers or alphabetical letters or even any ASCII characters, you can use PHP function range():
$a = range(0, 100, 2); // $a is an array of even integers from 0 to 100.
$b = range('a', 'z'); // $b now contains all lowercase alphabetic letters from a to z.
To create an array of a series of identical values, use function array_fill():
$dumb = array_fill(-10, 3, 'dumb');
$dumb is as follows:
Array
(
[-10] => 'dumb'
[-9] => 'dumb'
[-8] => 'dumb'
)
Yeah.
You should also read:
- PHP: Create an Array
- PHP: Check if A String Contain Only Uppercase / Capital Letters
- Regular Expressions for Natural Numbers or Positive Integers (1, 2, 3, …), Negative Integers and Non-negative Integers
- PHP: Count the Number of Occurrences of Each Unique Value in an Array
- PHP: Find and Return the Minimum (Lowest) Value or Maximum (Highest) Value of Several Numbers


Facebook
Twitter
Google Plus
{ 1 trackback }