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
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above

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
πŸ’¬ Discuss
βœ… Correct Answer: (B) array_diff() compares the values only while array_diff_assoc() compares the keys and values

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

  • (A) array_sort()
  • (B) sort()
  • (C) multisort()
  • (D) array_multisort()
πŸ’¬ Discuss
βœ… Correct Answer: (D) array_multisort()

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
πŸ’¬ Discuss
βœ… Correct Answer: (A) Sorts an indexed array

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

  • (A) sort_reverse()
  • (B) reverse_sort()
  • (C) revsort()
  • (D) rsort()
πŸ’¬ Discuss
βœ… Correct Answer: (D) rsort()

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

  • (A) get()
  • (B) start()
  • (C) current()
  • (D) cur()
πŸ’¬ Discuss
βœ… Correct Answer: (C) current()

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
πŸ’¬ Discuss
βœ… Correct Answer: (A) in_array()

Q. Which PHP function is used to sort an associative array in descending order, according to the key?

  • (A) rsort()
  • (B) sort()
  • (C) ksort()
  • (D) krsort()
πŸ’¬ Discuss
βœ… Correct Answer: (D) krsort()

Q. Which PHP function is used to get one or more random keys from an array?

  • (A) array_random()
  • (B) array_randomize()
  • (C) array_rand()
  • (D) krand()
πŸ’¬ Discuss
βœ… Correct Answer: (C) array_rand()

Q. Which is not a valid PHP superglobal variable?

  • (A) $GLOBALS
  • (B) $_SERVER
  • (C) $_ENV
  • (D) $_SESSIONS
πŸ’¬ Discuss
βœ… Correct Answer: (D) $_SESSIONS