1. Home
  2. Computer Science MCQs
  3. PHP
  4. Which in-built function will add a value to the end of an…

Added 19 Jan 2024

Which in-built function will add a value to the end of an array?

  1. array_unshift()
  2. into_array()
  3. inend_array()
  4. array_push() Correct answer

Correct answer

D. array_push()

15 views

MCQSEXAM

Explanation

array_push() adds one or more values to the end of an array and returns the new number of elements. For a single value, the shorthand $arr[] = $value does the same job slightly faster.

array_unshift() is its opposite and inserts at the beginning, while into_array() and inend_array() do not exist in PHP.

For more solved questions like this one, see Computer Science MCQs on MCQsExam.com.

Doubts & discussion

Not sure why the answer is D? 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