Send each value of an array to a function, multiply each value by itself, and return an array with the new values:


SUBMITTED BY: henry1874w

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

FORMAT: Text only

SIZE: 120 Bytes

HITS: 396

  1. <?php
  2. function myfunction($v)
  3. {
  4. return($v*$v);
  5. }
  6. $a=array(1,2,3,4,5);
  7. print_r(array_map("myfunction",$a));
  8. ?>

comments powered by Disqus