Code:
<form action="" method="post">
Enter Choice: <input type="text" name="search" />
<br />
Enter data to insert in array: <input type="text" name="data" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
<?php
if(isset($_POST['submit'])){
$array = array('india','bangladesh','nepal','bhutan');
$choice = $_POST['search'];
$data = $_POST['data'];
if($choice==1){
array_unshift($array,$data);
print_r($array);
}
else if($choice==2){
array_shift($array);
print_r($array);
}
else {
print "Wrong Choice";
}
}
?>
Comments
Post a Comment