PHP Array Push Key Value Example
May 28, 2021 . Admin
Hello Friends,
Now let's see example of how to push both value and key in php. This function can push both value and key. This is a short guide on php if push both value and key. The push function is used to push both value and key. Let's get started with array_push function in php.
Here i will give you example of how to use array_push function in php.
Syntax
#PHP
array_push(array, value1, value2, ...);Example 1:
The array_push() function inserts one or more elements to the end of an array.
<?php $a = array("laravel","php"); array_push($a,"css","bootstrap"); print_r($a); ?>Output:
Array ( [0] => laravel [1] => php [2] => css [3] => bootstrap )Example 2:
<?php $a=array("a"=>"cs","b"=>"cf"); array_push($a,"coa","html"); print_r($a); ?>Output:
Array ( [a] => cs [b] => cf [0] => coa [1] => html )It will help you....