2 Test is_array() function
5 /* Prototype: bool is_array ( mixed $var );
6 * Description: Finds whether the given variable is an array
9 echo "*** Testing is_array() on different type of arrays ***\n";
10 /* different types of arrays */
18 array(array(), array()),
19 array(array(1, 2), array('a', 'b')),
21 array("test" => "is_array"),
25 array("string", "test"),
26 array('string', 'test')
28 /* loop to check that is_array() recognizes different
29 type of arrays, expected output bool(true) */
31 foreach ($arrays as $var_array ) {
32 echo "-- Iteration $loop_counter --\n"; $loop_counter++;
33 var_dump( is_array ($var_array) );
36 echo "\n*** Testing is_array() on non array types ***\n";
38 // get a resource type variable
39 $fp = fopen (__FILE__, "r");
40 $dfp = opendir ( __DIR__ );
43 $unset_array = array(10);
46 // other types in a array
47 $varient_arrays = array (
65 10.0000000000000000005,
89 /* unset/undefined arrays */
93 /* loop through the $varient_array to see working of
94 is_array() on non array types, expected output bool(false) */
96 foreach ($varient_arrays as $type ) {
97 echo "-- Iteration $loop_counter --\n"; $loop_counter++;
98 var_dump( is_array ($type) );
102 /* close resources */
107 *** Testing is_array() on different type of arrays ***
139 *** Testing is_array() on non array types ***