PHP Common Array Application Note (_php) tutorial

Source: Internet
Author: User
Ange ($low, $high), Range ($low, $high, $step);//Create an array of sequential values such as: Range (1,4) as (1,2,3,4) and range (' A ', ' Z ')

Each ($array) returns the current element of the array sequentially, and sets the next element to the current element;

Reset ($array) sets the current element of the array back to the beginning of the array

List () can be used to decompose an array into a series of values, such as list ($a, $b) =each ($array)

Shuffle ($array), Array_rand ($arg, $num _req), random ordering of arrays

Array_reverse ($input), Array_reverse ($input, $preserve _keys) returns the reverse ordering of the original array

Sort ($array);

PHP Tutorial Array is an important concept, it contains a lot of functions, convenient for people to develop ... The array is now sorted to make it easy to query and apply.
Let's start with the definition of the PHP array ... the PHP array contains two items, key and value, which can be obtained by key, where key can be numeric and associative, such as $array[0], $array [one] ...
Create an array
The array declaration in PHP is a little bit different from other languages, but it can be declared as one-dimensional, two-dimensional, three-dimensional, multidimensional, etc.
$array [0] = 1, $array = Array (n/a); A one-dimensional array, which consists of only three values, is a numeric array, can be referenced with $array[0] to represent 1, and the index is omitted when creating a numeric array.

$array = Array (
1 = "One",
2 = "a",
3 = "three",
4 = Array (
"One" = 1,
"Both" = 2,
"Three" = 3
)
);

A two-dimensional array, which is also an associative array, can be $array[4]["one" to represent 1 when referenced.
More than three-dimensional ...
If you are creating an array in bulk, you can use the following function:
Array range (mixed low, mixed high [, number step])
such as $array = Range (1,6); represents array (1,2,3,4,5,6);
$array = range (a,f); Represents an array (a,b,c,d,e,f);

Output array
There are more functions in the output array in PHP, which are commonly used
BOOL Print_r (mixed expression [, bool return])
void Var_dump (mixed expression [, mixed expression [, ...]])
There are also like echo,print,printf that can output a single array.

1 2

http://www.bkjia.com/PHPjc/631343.html www.bkjia.com true http://www.bkjia.com/PHPjc/631343.html techarticle Ange ($low, $high), Range ($low, $high, $step);//create an array of sequence values such as: Range (1,4) is (1,2,3,4) and as range (' A ', ' Z ') each ($array) Returns the current element of the array in order, and the next ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.