The Php-arrays function-array_map-the callback function to the cell of the given array _php tutorial

Source: Internet
Author: User
Array_map () functions a callback function on a given array cell

function
The function will return an array,
The array contains all the cells in the array1 after the callback action.
The number of arguments received by the callback callback function should be the same as the number of arrays passed to the Array_map () function.
"Scope of Use"
php4>4.0.6, PHP5.
Use
Array Array_map (callback Callback,array Arr1[,array ...])
callback/Required/user-supplied callback function as a comparison standard
arr1/an array of required/used comparisons
Array.../an array of selectable/used comparisons
Example
[PHP]
Defining callback Functions
function cube ($n) {
Return ($n * $n * $n);
}
$a =array (1,2,3,4,5);
$b =array_map ("Cube", $a);
Var_dump ($b);
/*
Array (5) {
[0]=>
Int (1)
[1]=>
Int (8)
[2]=>
Int (27)
[3]=>
Int (64)
[4]=>
Int (125)
}
*/


Excerpts from Zuodefeng's notes

http://www.bkjia.com/PHPjc/478214.html www.bkjia.com true http://www.bkjia.com/PHPjc/478214.html techarticle Array_map () functions a callback function on a given array cell "function" The function returns an array that contains all the cells in the Array1 that have been callback-worked ...

  • 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.