Jump to content

jenskim

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

jenskim's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. aha. I'm seeing the light - I think that there may be spaces in the "ingredients" list. Thanks for that tip!
  2. Thanks Monkeyz... ya, it WORKS for me, but it's not returning ALL the matches. For instance, in the toxics list there is acetone and bleach. If I enter acetone, bleach as ingredients for a product, only acetone is displayed on the page. So, only the FIRST match shows.... Whah... very frustrating not understanding these things.
  3. Hello purples. I'm working on a project that wants to compare two arrays and display all matches. I'm almost there... comparing two arrays seems to be working, but only one piece of the match is displaying. List1 is a database field looking at ingredients that are entered by the user. List2 is a list of toxic ingredients. When a user enters a word that matches the list of toxics (list2) that word is displayed on the Web page. However only ONE of the matched words displays - when there are more than one matches. Anybody run into this? $list1 = $row['ingredients']; $list2 = array("2-butoxyethanol","acetone","ammonia","aerosol","bleach","butylcellosolve","d-limonene","DEA","diethyleneglyco","diethanolamine","ethoxylatednonylphenol","formaldehyde","fragrance","methylenechloride","monoethanolamine","morpholine","NPE","NTA","naphthalene","nonylphenolethoxylate","paraben","paradichlorobenzene","perchloroethylene","petroleum","phosphate","phosphoricacid","silica","sodiumdichloroisocyanuratedihydrate","sodiumhypochlorite","sodiumlaurylsulfatetoluene","trisodiumnitrilotriacetate","turpentine","xylene"); $tmp1 = explode(',',$list1);//ingredients $tmp2 = explode(',',$list2);//toxics for($i = 0; $i <count($tmp1); $i++){ $pieces = $tmp1[$i]; if (in_array($pieces, $list2)) { echo "<span style=\"color:red;\">Toxics exist: " . $pieces . "</span>"; } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.