Which function will return true if a variable is an array or false if it is not?
Correct answer
B. is_array()
11 views
B. is_array()
11 views
is_array() returns true when the variable passed to it is an array and false otherwise. It is typically used to validate input before looping over it with foreach.
Do not confuse it with in_array(), which searches for a value inside an array. this_array() and do_array() are not PHP functions.
Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.
Not sure why the answer is B? Ask here and get an explanation.