php array push – Best 3 Ways To add elements to an empty array in PHP?

Today, We want to share with you php array push.In this post we will show you array push key value, hear for array push to first index we will give you demo and example for implement.In this post, we will learn about How To Append An Item To Array In PHP? with an example.

php array push

Example 1 : PHP array_push() Function

<!DOCTYPE html>
<html>
<body>

<?php
$members=array("Dasrath","Ravan");
array_push($members,"Indrajit","Janaki");
var_dump($members);
?>

</body>
</html>

Example 2

<?php
$members= array('Madhavi','Palavi');
array_push($members,'Dhara','Kinara');
var_dump($members);
?>

Example 3

<?php
  $members = [
    'yang' => 'Indrajit',
    'old' => 'angel'
  ];
  array_push($members, 'kalguni', 'anjali');
  var_dump($members);
?>

I hope you get an idea about php array push.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.