PHP MCQs with answers Page - 29

Here, you will find a collection of MCQ questions on PHP. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 832.27K Points
Coach

Q. What is the difference between Indexed array and Associative array in PHP?

  • (A) Index array has numeric index while associative array has named keys
  • (B) Index array has numeric index while associative array has named keys and numeric index both
  • (C) Index array is one-dimensional array with numeric index while associative array is two-dimensional array with numeric index
  • (D) Index array has numeric index while associative array has one or more arrays

A

Admin • 832.27K Points
Coach

Q. Which is the correct example of an Indexed array in PHP?

  • (A) $cities = array("Delhi"; "Mumbai"; "Banglore");
  • (B) $cities = array("Delhi", "Mumbai", "Banglore");
  • (C) $cities = new array("Delhi", "Mumbai", "Banglore");
  • (D) $cities = new array(3) ("Delhi", "Mumbai", "Banglore");

A

Admin • 832.27K Points
Coach

Q. 111. Which is the correct example of an Associative array in PHP?

  • (A) $person = array("Alvin"=>"Delhi", "Alex"=>"Mumbai", "Bhavik"=>"Banglore");
  • (B) $person = array("Alvin"=>"Delhi"; "Alex"=>"Mumbai"; "Bhavik"=>"Banglore");
  • (C) $person = new array("Alvin"=>"Delhi", "Alex"=>"Mumbai", "Bhavik"=>"Banglore");
  • (D) $person = new array("Alvin"=>"Delhi"; "Alex"=>"Mumbai"; "Bhavik"=>"Banglore");

A

Admin • 832.27K Points
Coach

Q. Which PHP function(s) is/are used to compare arrays and returns the differences?

  • (A) array_diff()
  • (B) array_diff_assoc()
  • (C) array_diff_key()
  • (D) All of the above

A

Admin • 832.27K Points
Coach

Q. What is the difference between array_diff() and array_diff_assoc() functions?

  • (A) array_diff() compares the values only while array_diff_assoc() compares the keys only
  • (B) array_diff() compares the values only while array_diff_assoc() compares the keys and values
  • (C) Both functions can be used to compare the values and keys
  • (D) None of the above

A

Admin • 832.27K Points
Coach

Q. Which PHP function is used to sort multi-dimensional arrays?

  • (A) array_sort()
  • (B) sort()
  • (C) multisort()
  • (D) array_multisort()

A

Admin • 832.27K Points
Coach

Q. What is the use of PHP sort() function?

  • (A) Sorts an indexed array
  • (B) Sorts an associative array
  • (C) Sorts a multi-dimensional array
  • (D) Sorts any kind of array

A

Admin • 832.27K Points
Coach

Q. Which PHP function is used to sort an indexed array in descending order?

  • (A) sort_reverse()
  • (B) reverse_sort()
  • (C) revsort()
  • (D) rsort()

A

Admin • 832.27K Points
Coach

Q. Which PHP function is used to return the current element in an array?

  • (A) get()
  • (B) start()
  • (C) current()
  • (D) cur()

A

Admin • 832.27K Points
Coach

Q. Which PHP function is used to check if a specified value exists in an array?

  • (A) in_array()
  • (B) check_array()
  • (C) exist()
  • (D) None of the above

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ