Run each array element in a user-defined function:


SUBMITTED BY: henry1874w

DATE: June 26, 2017, 5:02 p.m.

FORMAT: Text only

SIZE: 174 Bytes

HITS: 209

  1. <?php
  2. function myfunction($value,$key)
  3. {
  4. echo "The key $key has the value $value<br>";
  5. }
  6. $a=array("a"=>"red","b"=>"green","c"=>"blue");
  7. array_walk($a,"myfunction");
  8. ?>

comments powered by Disqus