1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
if ($search != 'dRvHj8') {
						$search = strtolower(htmlspecialchars($search));
						$return = array();
						$stags = explode(" ", $search);
						$tolist = array();
						
						for ($ri = 0;$ri < count($stags);$ri++) {
							for ($i = 1; $i < count($njdbData); $i++) {
								$d = $i - 1;
								$info = explode('<+>', $njdbData[$d]); 
								if (strpos(strtolower($info[0]),$stags[$ri]) || strpos(strtolower($info[1]),$stags[$ri]) || strpos(strtolower($info[7]),$stags[$ri])) {
									$return[] = $d . '<+>' . $stags[$ri];
								}
							}
						}
						
						if (count($return)) {
							$taglist = $stags[0];
							$sep = ', ';
							if (count($stags) > 1) {
								if (count($stags) == 2) {
									$sep = ' och ';
								}
								for ($ri=1;$ri<count($stags)-1;$ri++) {
									$taglist = $taglist . $sep . $stags[$ri];
								}
								$taglist = $taglist . ' och ' . $stags[count($stags)-1];
							}
							
							echo '<div class="resultatSok">Visar resultat för '.$taglist.':</div>';
							
							$used_ones = array();
							
							for ($i = 0; $i < count($return); $i++) {
								$herb = explode('<+>',$return[$i]);
								$inf = explode('<+>', $njdbData[$herb[0]]);
								if (!in_array($herb[0], $used_ones)) {
									echo '<div class="herbListItem" onclick="goToHerb(' . $herb[0] . ')"><img src="../img/herbs/' . $inf[2] . '-2.jpg" /> <span>'.$inf[0].'</span></div>';
									array_push($used_ones, $herb[0]);
								}
							}
						}
						else {
							echo '<div class="resultatSok">Vi hittade inte '.$search.'...</div>';
						}
					}