Answer the question
In order to leave comments, you need to log in
PHP search not working on csv file?
There is a function that searches the csv file for matches
function find_value($filename, $value) {
$f = fopen($filename, "r");
$result = 'false';
while ($row = fgetcsv($f, 0,";")) {
if ($row[0] == $value) {
$result[] = array($row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6]);
break;
}
}
fclose($f);
return $result;
}
echo(find_value('libs/cities/city.csv', 'Ярославль'));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question