Answers for "add more element in existing array of php"

PHP
2

php array append

<?php
$stack = array("orange", "banana");
array_push($stack, "apple", "raspberry");
print_r($stack);
?>
Posted by: Guest on October-01-2020
1

php add array to array

$a = array('a','b','c');
$b = array('c','d','e');

array_push($a, ...$b);
print_r($a);
/*
notice this is different than array merge as it does not merge
values that the same 
Array
(
    [0] => a
    [1] => b
    [2] => c
    [3] => c
    [4] => d
    [5] => e
)
*/
Posted by: Guest on February-22-2022

Code answers related to "add more element in existing array of php"

Browse Popular Code Answers by Language