Which of the following functions is used to insert a new element in the beginning of an array?
array_unshift()
Correct:
array_unshift()
Explanation: Answer option B is correct.
The array_unshift() function is used to insert a new element in the beginning of an array. The return value of the array_unshift() is the new number of elements in the array. The syntax of the array_unshift() function is as follows:
array_unshift(array,value1,value2,value3...)
Answer option C is incorrect. The array_pop() function deletes the last element of an array.
Answer option D is incorrect. The array_push() function inserts one or more elements to the end of an array.
Answer option A is incorrect. The array_unique() function removes the duplicate values from the given array.