Re: Finding a value in an array

From: Date: Fri, 23 Jul 2004 03:39:52 +0000
Subject: Re: Finding a value in an array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-191604@lists.php.net to get a copy of this message
On Thu, 22 Jul 2004 23:34:56 -0400, charles kline <ckline@rightcode.net> wrote: > Hi all, > > I am using fgetcsv() to get a tab delimited text file into an array. It > gives me an array in this format: > > Array > ( > [0] => Array > ( > [0] => 97 > [1] => Effects of Slow Heating Rates on Products of > Polyethylene Pyrolysis > ) > > [1] => Array > ( > [0] => 103 > [1] => Effect of Heating Rate of Oxidative Degradation of > Polymeric Materials > ) > > [2] => Array > ( > [0] => 106 > [1] => Identification and Differentiation of Synthetic > Polymers by Pyrolysis Capillary Gas Chromatography > ) > ) > > From a form, I am passing in some values from checkboxes like: > > <input type="checkbox" name="notes[]" value="97" /> > <input type="checkbox" name="notes[]" value="106" /> > > I need to be able to display the description string in the array for > whichever checkboxes are checked. So for example if the user submits > the form with the value "106" I want to display "Identification and > Differentiation..." > > Any ideas? Please copy me on replies. > Just loop through and check... foreach($csvArray as $entry) { if(in_array($entry[0], $_REQUEST['notes'])) { echo $entry[1].'<br/>; } } -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin--

« previous php.general (#191604) next »