In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "what common array functions php has", which is easy to understand and clear, hoping to help you solve your doubts. Let me lead you to study and learn about "what common array functions php has".
The details are as follows:
1. Array array_merge (array $array1 [, array $array2 [, $array]])
Function function: merges the cells of one or more arrays, and the values in one array are appended to the previous array. Returns an array of results.
If you enter an array with the same string key name, the value after that key name overwrites the previous value. However, if the array contains numeric key names, the subsequent values will not overwrite the original values, but will be appended to them.
If only one array is given and the array is numerically indexed, the key name is re-indexed in a continuous manner.
Example 1: there is the same string key name in the array
$array1=array ('color'= >' greed','3'= > 8); $array2=array ("a", 'color'= > "red",' 3 minutes = > 8); var_dump (array_merge ($array1,$array2))
Output:
Array (4) {["color"] = > string (3) "red" [0] = > int (8) [1] = > string (1) "a" [2] = > int (8)}
The color with duplicate key names is overwritten, and only the following value 'red',' and'3' with the same number key name are not overwritten, but appended to the back.
2. Array array_slice (array $array,int $offset, [int $length [, bool $preserve_keys]])
Function function: returns a sequence in the array array specified according to the offset and length parameters.
If offset is non-negative: the array starts with the offset from the beginning to the offset. $array=array (1 array,2); $5); array_slice ($5); equivalent to (1 mine2, 3, 4, 5, 5); red represents the intercepted array
If offset is negative: the array starts with the offset from the end to the offset. Array_slice ($array,-2); equivalent to (1, 2, 3, 4, 4, 5, 5)
If length is positive: the number of intercepts from offset. Array_slice ($array,2,2); equivalent to (1, 2, 3, 4, 4, 5, 5)
If length is negative: the sequence will end so far from the end of the array; array_slice ($array,2,-1); equivalent to (1, 2, 3, 4, 5, 6)
The default is: to the end of the array.
3. Array_map (callback $callback, array $arr1 [, array $.])
Function function: returns an array containing all the units in arr1 after the action of callback. The number of parameters accepted by callback should be the same as the number of arrays passed to the array_map () function.
Output:
Array ([0] = > 1 [1] = > 8 [2] = > 27 [3] = > 64 [4] = > 125) the above is all the contents of this article "what are the common array functions in php?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.