1. Home
  2. Computer Science MCQs
  3. PHP
  4. Which function will return true if a variable is an array…

Added 19 Jan 2024

Which function will return true if a variable is an array or false if it is not?

  1. this_array()
  2. is_array() Correct answer
  3. do_array()
  4. in_array()

Correct answer

B. is_array()

11 views

MCQSEXAM

Explanation

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.

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More PHP MCQs

Practise all PHP MCQs

Similar MCQs