note 36336 deleted from function.array-search by didou
| From: | didou@php.net | Date: | Mon, 15 Dec 2003 18:29:13 +0000 |
| Subject: | note 36336 deleted from function.array-search by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-61998@lists.php.net to get a copy of this message | ||
Note Submitter: itranga@hotmail.com
----
<?php
//This Is a Function For Seraching For a Value In an Array.
//Add Values To Array
$map[0] = array(Name => "Ranga" , Age => "20");
$map[1]= array(Name => "Ravi", Age => "30");
$map[2]= array(Name => "Kanc", Age => "20");
$val = "20"; //Value we Are Going To Search For
// Calling Function
search($map, $val);
//Function
function search($map, $val)
{
$count = 0 ;
foreach($map as $key => $row)
{
foreach($row as $key1 => $cellvalue)
{
if($cellvalue == $val)
{
print $count . "----->" . $row[Name];
$count = $count + 1;
echo "<br/>";
}
}
}
}
?>
// Please email me if you have any comments