Beginner PHP
Q21 / 100

What is the difference between array_push() and $arr[] = ?

Correct! Well done.

Incorrect.

The correct answer is B) They are functionally equivalent; $arr[] is slightly faster as it avoids function call overhead

B

Correct Answer

They are functionally equivalent; $arr[] is slightly faster as it avoids function call overhead

Explanation

Both append to the end of an array. $arr[] = $val is preferred for single elements; array_push($arr, $a, $b) for multiple at once.

Progress
21/100