note 36336 added to function.array-search

From: Date: Mon, 06 Oct 2003 09:33:17 +0000
Subject: note 36336 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-57885@lists.php.net to get a copy of this message
<?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 ---- Manual Page -- http://www.php.net/manual/en/function.array-search.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36336 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36336&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36336&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#57885) next »