Programming MCQs Feed

📊 PHP
Q. Which PHP function returns the current element of an array?
  • (A) current()
  • (B) next()
  • (C) key()
  • (D) value()
💬 Discuss
✅ Correct Answer: (A) current()

Explanation: current() returns the element at the current pointer position.

📊 PHP
Q. Which PHP function advances the internal array pointer?
  • (A) advance()
  • (B) next()
  • (C) forward()
  • (D) move()
💬 Discuss
✅ Correct Answer: (B) next()

Explanation: next() moves the pointer forward.

📊 PHP
Q. Which PHP function moves the array pointer backward?
  • (A) prev()
  • (B) back()
  • (C) previous()
  • (D) rewind()
💬 Discuss
✅ Correct Answer: (A) prev()

Explanation: prev() moves the internal pointer backward.

📊 PHP
Q. Which PHP function returns the key of the current array element?
  • (A) key()
  • (B) index()
  • (C) current_key()
  • (D) array_key()
💬 Discuss
✅ Correct Answer: (A) key()

Explanation: key() returns the key of the current element.

📊 PHP
Q. Which PHP function checks if a value exists in an array?
  • (A) array_key_exists()
  • (B) in_array()
  • (C) array_search()
  • (D) value_exists()
💬 Discuss
✅ Correct Answer: (B) in_array()

Explanation: in_array() checks for the presence of a value.

📊 PHP
Q. Which PHP function searches a value and returns its key?
  • (A) in_array()
  • (B) array_key_exists()
  • (C) array_search()
  • (D) search_array()
💬 Discuss
✅ Correct Answer: (C) array_search()

Explanation: array_search() returns the key if the value is found.

📊 PHP
Q. Which PHP function counts occurrences of values in an array?
  • (A) array_count()
  • (B) count_values()
  • (C) array_count_values()
  • (D) value_count()
💬 Discuss
✅ Correct Answer: (C) array_count_values()

Explanation: array_count_values() counts frequency of values.

📊 PHP
Q. Which PHP function extracts variables from an array?
  • (A) array_extract()
  • (B) extract()
  • (C) import()
  • (D) vars()
💬 Discuss
✅ Correct Answer: (B) extract()

Explanation: extract() imports array keys as variable names.

📊 PHP
Q. Which PHP function compacts variables into an array?
  • (A) array_pack()
  • (B) compact()
  • (C) collect()
  • (D) vars_to_array()
💬 Discuss
✅ Correct Answer: (B) compact()

Explanation: compact() creates an array from variables.

📊 PHP
Q. Which PHP function delays execution for a number of seconds?
  • (A) sleep()
  • (B) wait()
  • (C) pause()
  • (D) delay()
💬 Discuss
✅ Correct Answer: (A) sleep()

Explanation: sleep() delays execution in seconds.