PHP Learning Array Value Operations_PHP Tutorial

WBOY
Release: 2016-07-21 15:30:53
Original
694 people have browsed it

1. Extraction of values ​​
In PHP, list is used to extract the values ​​in the array, such as list($a, $b) = $array. If there are more values ​​in the list than the number of arrays, the excess values ​​in the list will be set to NULL. You can also use commas to skip values ​​in the array, such as list($a, ,$b) = $array.

2. Divide the array
If you want to get the sub-array, you can use array_slice(array, offset, length); to get it. It returns a new array with indexes starting from 0. If the subscript of the original array is a string, it seems to be meaningless, so it is best not to use it. You can use array_splice to obtain the substring.

3. Divide the array into multiple arrays
Use array_chunk to divide the array into a two-dimensional array. For details, you can read the official instructions through the link.

4. Keys and values ​​
array_keys($array), get the array composed of array index
array_value($array), get the array composed of array value, the index is from 0 Start reallocation.
array_key_exists($key, array), check whether the element exists.
array_splice, delete inserted elements.

5. Conversion between arrays and variables
extract(array) turns arrays into variables
compact() turns variables into arrays

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323145.htmlTechArticle1. Extraction of values ​​In PHP, use list to extract the values ​​in the array, such as list($a , $b) = $array. If there are more values ​​in the list than the number of arrays, the excess values ​​in the list will be set to NULL. You can also use commas to...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!