This article introduces the content is about using the range function to create an array, has a certain reference value, now share to everyone, the need for friends can refer to
Array Traversal language
--Quickly create an array
--range (1,5)
What does this range function mean? Who is the key? Who is the value? Range is a quick-create array
Function. The functions provided by PHP to quickly create an array include range (), explode (),
Array_combine (), Array_fill (), and Array_pad (). The rest of the functions should be ignored.
Yes. Focus on the range () function.
Syntax format, Arrge range (mixed start,mixed end)
function function: Quickly create a numeric array or a character array from start to end range.
Note that if start>end, the sequence will be descending from start to end.
Here, let's give an example,
<?php$numbers = range (1,5);//An array called numbers with five values in it. Array (1,2,3,4,5) Print_r ($numbers);/* output, array ([0]=>1 [1]=>2] [2]=>3 [3]=>4] * Front is key, followed by value 4]=>5 What if it's a string? It's not a number. $chars1 = Range (' A ', ' d ');//chars is a character. The start sequence is a, the end sequence is Dprint_r ($chars 1);/* The value inside the output array. *array ([0]=>a [1]=>b] [2]=>c [3]=>d] */?>
Summarize, create an array, and then iterate over the array. The limit can only be a regular sequence. If nothing
Law, then helpless.