Re: [PHP] Finding a value in an array

2004-07-22 Thread Justin Patrin
On Thu, 22 Jul 2004 23:34:56 -0400, charles kline [EMAIL PROTECTED] 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



Re: [PHP] Finding a value in an array

2004-07-22 Thread charles kline
Thanks!!!
On Jul 22, 2004, at 11:39 PM, Justin Patrin wrote:
On Thu, 22 Jul 2004 23:34:56 -0400, charles kline 
[EMAIL PROTECTED] 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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php