26)Write a menu driven program in PHP to perform the following operations on an associative array:
i.Display the elements of an array along with the keys.
ii.Display the size of an array
iii.Delete an element from an array from the given index.
iv.Reverse the order of each element’s key-value pair
v.Traverse the elements in an array in random order.
26.html
<html>
<body>
<form action=slip26.php method=get>
<input type=Radio value=1 name="chk">Display</br>
<input type=Radio value=2 name="chk">Size</br>
<input type=text name=in></br>
<input type=Radio value=3 name="chk">Delete </br>
<input type=Radio value=4 name="chk">Reverse </br>
<input type=Radio value=5 name="chk">Random</br>
<input type=Submit value=SUBMIT></br>
</form>
</body>
</html>
slip26.php
<?php
$i=$_GET['in'];
$ch=$_GET['chk'];
$a=array("a"=>1,"b"=>2,"c"=>4,"d"=>3);
if($ch==1)
{
// print_r($a);
foreach($a as $k=>$val)
{
echo "$k=>$val</br>";
}
}
else if($ch==2)
{
echo count($a);
}
else if($ch==3)
{
unset($a[$i]);
echo "element deleted";
print_r($a);
}
else if($ch==4)
{
print_r(array_flip($a));
}
else if($ch==5)
{
shuffle($a);
print_r($a);
}
else
echo "Invalid Option";
?>