note 49248 added to function.array-search

From: Date: Fri, 21 Jan 2005 12:37:46 +0000
Subject: note 49248 added to function.array-search
Groups: php.notes 
Request: Send a blank email to php-notes+get-83726@lists.php.net to get a copy of this message
If you want to search in a multi-dimensional array and just a portion, not the whole value, try this. <? $Projects[0] = array(123, "Text 1"); $Projects[1] = array(456, "Text 2"); $Projects[2] = array(789, "Text 3"); $search_value = "ext 2"; foreach ($Projects as $key => $row) { foreach($row as $cell) { if (strpos($cell, $search_value) !== FALSE) { echo "<p>".$key; } } } ?> ---- Manual Page -- http://www.php.net/manual/en/function.array-search.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49248 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49248&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49248&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49248&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49248&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49248&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49248&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83726) next »