array_walk() function in PHP

WBOY
Release: 2023-08-27 08:06:01
forward
814 people have browsed it

array_walk() function in PHP

The array_walk() method applies a user-defined function to each member of an array. Returns TRUE on success and FALSE on failure.

Syntax

array_walk(arr, custom_func, parameter)
Copy after login

Parameters

  • arr- The specified array. Required.

  • custom_func- User-defined function. Required.

  • #parameter- Parameters set for the custom function. Optional.

Return value

The array_walk() function returns TRUE on success and FALSE on failure.

Example

The following is an example-

Live Demo

"; } $arr = array("p"=>"Tom","q"=>"Jack","r"=>"Amit"); array_walk($arr,"display"); ?>
Copy after login

Output

The following is the output-

p id : Student Tom q id : Student Jack r id : Student Amit
Copy after login

The above is the detailed content of array_walk() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!