PHP function---Array function array_map ()

Source: Internet
Author: User

/*function Array_map () function: Most group callback function---The function of the callback function to the cell of the given array * 1, Syntax: Array Array_map (callback callback, array arr1 [, array ...]) * 2. Description: Returns an array that contains all the cells in the ARR1 after the callback action.   The number of arguments callback accepts should be the same as the number of arrays passed to the Array_map () function. * 3, NOTE: * 3.1, most of the group callback function in an array, the original array will retain the key name, that is, the key name of the returned array is * action to the given array of key name * 3.2, most of the group back to the function of two or more arrays, their length is consistent, and will ignore the original Multiple arrays of * key names, uniformly assigned numeric indexes as key names*/  //examples of single array use  $websites=Array("G" = "google", "b" = "Baidu", "Y" and "Yahoo"); //Output Original Array  Echo"<pre>"; Print_r($websites); Echo"</pre>"; //defines a callback function for handling a single array  functionChange_value ($value){      return Ucfirst($value).". com; }  $urls=Array_map(' Change_value ',$websites); Echo"<pre>"; Print_r($urls); Echo"</pre>"; //examples of multiple arrays used  $arr 1=Array(1,3,5,7); $arr 2=Array(2,4,6,8); //defining callback functions for handling multiple arrays  functionFunc1 ($a,$b){      return $a*$b; }  $results=Array_map(' Func1 ',$arr 1,$arr 2); Echo"After processing multiple arrays using a callback function, the result returned is:<br>"; Echo"<pre>"; Print_r($results); Echo"</pre>";

Output Result:

Reprinted from: http://www.cnblogs.com/zydcl/archive/2011/07/10/2102140.html#undefined

PHP function---Array function array_map ()

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.