SearchArray.php
<?php
	class SearchArray
	{
		function search($arr,$n,$no)
		{
			$pos=0;
			for($i=0;$i<$n;$i++)
			{
				if($arr[$i]==$no)
				{
					$pos=$i+1;
					$flag=true;
					break;
				}
			}
			return $pos;
		}
	}
?>
index.php
<?php
	require("SearchArray.php");
	$obj=new SearchArray();
	$array=array(1,2,3,4,5);
	$pos=$obj->search($array,5,1);
	if($pos>0)
		echo "Found at ".$pos." position";
	else
		echo "Not foud";
?>

Leave a Reply

Your email address will not be published. Required fields are marked *

four × one =