Filter the values of an array using a callback function:


SUBMITTED BY: henry1874w

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

FORMAT: Text only

SIZE: 128 Bytes

HITS: 283

  1. <?php
  2. function test_odd($var)
  3. {
  4. return($var & 1);
  5. }
  6. $a1=array("a","b",2,3,4);
  7. print_r(array_filter($a1,"test_odd"));
  8. ?>

comments powered by Disqus