There is an array derived from a file with the .csv extension.
$data = file("file.csv"); And there is a text received from the input through the global $ _POST array
$text = $_POST['text']; You need to do a search for matching the text with the value in the array. I tried this:
if (in_array($text, $data)) { echo "Совпадение найдено"; } else { echo "Совпадений не найдено"; } For some reason does not find matches. I even tried this:
foreach ($data as $key => $value) { if($text == $value) { echo "Совпадение найдено"; } else { echo "Совпадений не найдено"; } } It still doesn’t find anything (although $ text delivers on purpose identical to one of the array values).
What could be the problem? How to search?