import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-array / array_filter_variation6.php
blob127489cf019229013a78b673024f9dc59f68f5a4
1 <?php
2 /* Prototype : array array_filter(array $input [, callback $callback])
3 * Description: Filters elements from the array via the callback.
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * Passing 'input' array which contains elements as reference to other data
9 */
11 echo "*** Testing array_filter() : usage variations - 'input' containing references ***\n";
13 // Callback function
14 /* Prototype : bool callback(array $input)
15 * Parameter : $input - array of which each element need to be checked in function
16 * Return Type : returns true or false
17 * Description : This function checks each element of an input array if element > 5 then
18 * returns true else returns false
20 function callback($input)
22 if($input > 5) {
23 return true;
25 else {
26 return false;
30 // initializing variables
31 $value1 = array(1, 2, 8);
32 $value2 = array(5, 6, 4);
33 $input = array(&$value1, 10, &$value2, 'value');
35 // with 'callback' argument
36 var_dump( array_filter($input, 'callback') );
38 // with default 'callback' argument
39 var_dump( array_filter($input) );
41 echo "Done"