This article explains adding and removing Array Elements in PHP.
Introduction
This article explains adding and removing Array Elements in PHP. For this explanation I used some functions for adding and removing array elements. These functions are very important and useful to us in an array for adding and removing array elements.
Syntax
This function adds elements to the start of an array.
Array_unshift($array ,$var);
Example
<?php
$name = array("John", "Tom");
array_unshift($name, "Jony", "Richy");
echo "<pre>";print_r($name);
?>
Output
This function removes elements from the start of an array.
Array_shift($array);
$name = array("John", "Tom", "Jony", "Richy");
array_shift($name);
This function adds elements to the end of an array.
Array_push($array ,$var);
array_push($name, "Jony", "Richy");
This function removes elements from the end of an array.
Array_pop($array);
array_pop($name);
Pro WPF: Windows Presentation Foundation in .NET 3.0