Using a user-made function to change the values of an array:


SUBMITTED BY: henry1874w

DATE: June 23, 2017, 9:42 p.m.

FORMAT: Text only

SIZE: 169 Bytes

HITS: 328

  1. <?php
  2. function myfunction($v)
  3. {
  4. if ($v==="Dog")
  5. {
  6. return "Fido";
  7. }
  8. return $v;
  9. }
  10. $a=array("Horse","Dog","Cat");
  11. print_r(array_map("myfunction",$a));
  12. ?>

comments powered by Disqus