In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the example analysis of the comparison between array_map and array_walk in php. The article is very detailed and has certain reference value. Interested friends must read it!
Array_map ():
1. The array_map () function acts the user-defined function on each value in the array and returns the array with new values after the user-defined function. If there is no return value after the function, the corresponding new value array is empty.
2.The number of arguments accepted by the callback function should be the same as the number of arrays passed to the array_map () function.
3. Tip: you can enter one or more arrays into the function.
If the phase function inputs two arrays, the function should also have two parameters. When map passes the value to the function, it takes one from the two arrays each time to pass to the function. That is, multiple arrays are submitted synchronously, instead of submitting one array and then submitting several arrays next, the function also needs to have several parameters.
4. Syntax: array array_map (callable callback,array arr1 [, array $... ])
Example:
Array_walk ():
1. Array_walk-use user-defined functions to callback each element in the array
2. Syntax: bool array_walk (array & array,callable funcname [, mixed $userdata = NULL])
Parameters:
An array entered by $array. The $funcname callback function, which typically takes two parameters for $funcname. The value of the $array parameter is the first, and the key name is the second. $userdata if the optional parameter $userdata is provided, it will be passed to $funcname as the third parameter.
Note:
If $funcname needs to act directly on the values in the array, the first parameter to funcname is specified as a reference (adding the & symbol). In this way, any changes to these units will also change the original array itself.
Return value:
Returns TRUE on success or FALSE on failure.
Example:
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.