Home >Backend Development >PHP Tutorial >photoshop learning PHP learning array value operations
1. Value extraction
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. 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 reallocated from 0.
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
The above introduces the operations of array values in photoshop learning and PHP learning, including the content of photoshop learning. I hope it will be helpful to friends who are interested in PHP tutorials.