Re: Finding a value in an array

From: Date: Fri, 23 Jul 2004 04:08:11 +0000
Subject: Re: Finding a value in an array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-191605@lists.php.net to get a copy of this message
Thanks!!! On Jul 22, 2004, at 11:39 PM, Justin Patrin wrote:
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-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#191605) next »