Answers for "add at the end of an array php"

PHP
68

php append to array

$myArr = [1, 2, 3, 4];

array_push($myArr, 5, 8);
print_r($myArr); // [1, 2, 3, 4, 5, 8]

$myArr[] = -1;
print_r($myArr); // [1, 2, 3, 4, 5, 8, -1]
Posted by: Guest on January-21-2020
2

php add element to array

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

Code answers related to "add at the end of an array php"

Browse Popular Code Answers by Language