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]
<?php
array_push ( array $array [, mixed $… ] );
?>
[/php]

How to push multiple elements into array using array push

This is how to add multiple variables into an array;

[php]
<?php
array_push($array, $variable1, $variable2, $variable3…….);
?>
[/php]

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




Similar Posts