Array function library: Array_walk

Source: Internet
Author: User
Keywords array_walk php Chinese function manual array function library
Tags aliyun array array function library array_walk custom function function library functions

Array_walk

(PHP3 >= 3.0.0, PHP4)

Array_walk---Enables custom functions to handle each element of an array

Grammar: int&http://www.aliyun.com/zixun/aggregation/37954.html ">NBSP;" Array_walk (Array arr, string func);

Description:

Arr each element of the array and the function name Func, the element is passed to the first argument of the function func, and if the function func more than one parameter, a warning message can be suppressed to suppress the warning message by adding ' @ ' to the function, or @array_walk, or by using the Error_ Reporting。

Note: This function does arr each element of the array, so any change in the element will affect the array itself.

Note: PHP4.0. New transfer index (key) and user data (UserData) to function func. In PHP4, Array_walk () preset does not reset (reset) array, so you must call reset ()

Example:

<?php

$fruits = Array ("D" => "Lemon", "a" => "Orange", "B" => "banana", "C" => "Apple");

function Test_alter ($item 1) {

$item 1 = ' bogus ';

}

function Test_print ($item 2) {

echo "$item 2<br>\n";

}

Array_walk ($fruits, ' test_print ');

Reset ($fruits);

Array_walk ($fruits, ' test_alter ');

Reset ($fruits);

Array_walk ($fruits, ' test_print ');

?>

Reference: each () List ()

Related Article

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.