In this article, We’ll see how to append an item to array in php.
we’ll use array_push()
function because it’ll inserts one or more elements to the end of an array.
Insert “Node Js” and “Express Js” to the end of an array:
$array = array("Java", "Php", "C++"); array_push($array, "Node Js", "Express Js"); echo "<pre>"; print_r($array); echo "</pre>";
Output:
Array ( [0] => Java [1] => Php [2] => C++ [3] => Node Js [4] => Express Js )
That’s it!. Please share your thoughts or suggestions in the comments below.
This is really interesting, You’re a very skilled blogger.
I’ve joined your rss feed and look forward to seeking more of your great post.
Also, I have shared your web site in my social networks!