How to use array_walk() function in php?

array_walk() Method: It applies a user-defined function to every member of an array. The array’s keys and values are parameters in the function PHP. The array_walk() function is not affected by the internal array pointer of the array PHP.

1. Syntax:

Syntax:

array_walk(array, myfunction, parameter...)

Parameters:

    - array: The input array.
    - myfunction: Name of the function
    - parameter: Specifies a parameter to the user-defined function. You can assign multiple parameters.

2. Example:

Code:

<?php  
  function myfunction($value,$key) {  
    echo "Soltuts $key is about $value \n";  
  }  
  $articles = array(
    "article-1" => "HTML",
    "article-2" => "CSS",
    "article-3" => "PHP"
  );  
    
  array_walk($articles,"myfunction");  
?>

Output:

Soltuts article-1 is about HTML
Soltuts article-2 is about CSS
Soltuts article-3 is about PHP