How can the PHP array_push function be used effectively to add multiple elements to an array in a loop?

When adding multiple elements to an array in a loop, the array_push function can be used effectively by iterating through the elements and pushing each one onto the array inside the loop. This allows for a dynamic way to add elements without specifying each element individually.

$myArray = array();
$elementsToAdd = array(1, 2, 3, 4, 5);

foreach($elementsToAdd as $element){
    array_push($myArray, $element);
}

print_r($myArray);