Run each array element in a user-defined function:


SUBMITTED BY: henry1874w

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

FORMAT: Text only

SIZE: 217 Bytes

HITS: 216

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

comments powered by Disqus