Please Like our Facebook Page

How to Push Multiple Elements into an Array using array_push()


PHP HOW TO ADD MULTIPLE VALUES INTO AN ARRAY USING ARRAY_PUSH

You might have come to a situation where you need to add more than one element into an array using array_push. Array_push() treats array as a stack and pushes the added element into the end of the array. Array increases with number of variables pushed.

General Syntax of array_push()

<?php
     array_push ( array $array [, mixed $... ] );
?>

How to push multiple elements into array using array push

This is how to add multiple variables into an array;

<?php
     array_push($array, $variable1, $variable2, $variable3.......);
?>

With array push, you can add as many values as you wish.













Please Like us on Facebook