Friday, 13 April 2018

WT-Slip27

27)Write a PHP Script for the following:
a.Declare a Multidimensional Array.
b.Display specific element from a Multidimensional array.
c.Also delete given element from the Multidimensional array.
d.Display an array.
e.Search a given element from an array.


Slip27.html

<html>
<form action=slip27.php method=get>
<input type=text name=number ></br>
<input type=submit value="SUBMIT">
</form>
</html>



slip27.php


<?php
$b=$_GET['number'];
$a=array(array(1,2),array(3,4));
//echo $a[1][1];
echo "</br>";
function deleteelement($e)
{
global $a;                 
for($i=0;$i<Count($a);$i++)
{
for($j=0;$j<Count($a[$i]);$j++)
{
if($a[$i][$j]==$e)
{
echo "Element Found</br>";
unset($a[$i][$j]);
echo "Element Deleted";
}
}
}
}
deleteelement($b);
print_r($a);
$c=range("a","z");
if(in_array($b,$c))
{
echo "FOund";
}
else
echo "Not Found";
?>