I have imported a CSV to fill a multidimensional array. $arrCSV.
<?php
$foundOneMatchingRow = FALSE;
foreach ($arrCSV as $row) {
if (strpos($row['5'], $val) !== FALSE && strlen($row['5']) > 4) {
$foundOneMatchingRow = TRUE;
echo $row['6'];
}
}
?>
The above code outputs from the value of $val = $_GET['menu']; which is done buy the URL.
I would like to make a search if possible please based on words in $row['6'];.
There will be a search on the page which will pass the search to the URL.
Which would look something like http://example.com/search.php?val=dogs
So the code would look for ANYTHING that relates to dog in $row [6]
I hope I have been clear. Any gudiance would be more than welcome. I am testing everything now.
Thank you
if (strpos($row['6'], $val) !== FALSE)will evaluate to true if$row['6']contains “dog” (if$val‘s value is “dog”). That is, will evaluate to true as well if the string in$row['6']is “bulldog” or “whateverdogwhatever”.BTW, why do you need this condition:
strlen($row['5']) > 4? (which I guess should be at leaststrlen($row['6']) > 4if you search on$row['6']).Something else: aren’t you confusing strings and integers? Maybe
if (strpos($row['6'], $val) !== FALSE)should beif (strpos($row[6], $val) !== FALSE)?EDIT
I would suggest to define constants for your CSV columns, for readability.
What about for example: