Which in-built function will add a value to the end of an array?
Correct answer
D. array_push()
15 views
D. array_push()
15 views
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.
Not sure why the answer is D? Ask here and get an explanation.