PHP

PHP Menu

PHP

array_walk_recursive() Function - Definition, Syntax, Parameters, Examples

Definition

The array_walk_recursive() function is used to create a PHP array.

Syntax

array_walk_recursive(array, myfunction, parameter...)

Parameters

Parameter Description
array Required. Specifying an array.
myfunction Required. The name of the user-defined function.
parameter... Optional. Specifies a parameter to the user-defined function. You can assign one parameter to the function, or as many as you like.

Example

<?php
function myFunction($item, $key) { echo "$key - $item <br>"; }
$ages = array("Mark" => 22, "Jeff" => 32, "Mike" => 28); $persons = array("ages"=>$ages, "country" => "USA"); array_walk_recursive($persons, "myFunction");

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods