Basic functions of PHP array operations

Source: Internet
Author: User

The key name and value of the array
Array_values ($arr); Get the value of an array
Array_keys ($arr); Gets the key name of the array
Array_flip ($arr); the values in the array are exchanged with the key names (if there are duplicates, the previous one will be overwritten by the following)
In_array ("Apple", $arr); Retrieve Apple in an array
Array_search ("Apple", $arr); Retrieve Apple in an array if there is a return key name
Array_key_exists ("Apple", $arr); Retrieves whether the given key name exists in the array
Isset ($arr [Apple]): Retrieves whether the given key name exists in the array

An internal pointer to an array
Current ($arr); Returns the cell in the array
POS ($arr); Returns the current cell in the array
Key ($arr); Returns the key name of the current cell in the array
Prev ($arr); Rewind the internal pointer in the array back to a
Next ($arr); Move the inner pointer in the array forward one
End ($arr); point the inner pointer in the array to the last cell
Reset ($arr; point the inner pointer in the array to the first cell
Each ($arr), constructs an array that returns a key name/value of the current element of the array, and moves the array pointer forward one
List ($key, $value) =each ($arr); Gets the key name and value of the current element of the array

Conversions between arrays and variables
Extract ($arr); used to convert an element in an array into a variable and import it into the current file, the key name as the variable name, and the value as the variable value
Note: (The second parameter is very important, can see the manual use) method of use echo $a;
Compact (VAR1,VAR2,VAR3); Create an array with the given variable name

Basic functions for PHP array operations

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.