array_filter in Php Example - Php

How to use array-filter in php ?

Snippet Code

Rate this page :
  [ 0 votes]

Here, array_filter() function is used to filter the values of an array. Function checkarray passes each input array value to the callback function. This php code displays only array values less than 10.

<?php function checkarray($i) { return ($i < 10); } $arr = array(3,5,7,10,2,15,17); $filter_arr = array_filter($arr, 'checkarray'); print_r($filter_arr); ?>


Ask Questions

Ask Question