- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
array_walk() function in PHP
The array_walk() method applies a user-defined function to every member of an array. It returns TRUE on success and FALSE on failure.
Syntax
array_walk(arr, custom_func, parameter)
Parameters
arr − The specified array. Required.
custom_func − The user defined function. Required.
parameter − The parameter to be set for the custom function. Optional.
Return
The array_walk() function returns TRUE on success and FALSE on failure.
Example
The following is an example −
<?php function display($val,$key) { echo "$key id : Student $val<br>"; } $arr = array("p"=>"Tom","q"=>"Jack","r"=>"Amit"); array_walk($arr,"display"); ?>
Output
The following is the output −
p id : Student Tom q id : Student Jack r id : Student Amit
Advertisements