K
K
krispey1012021-06-09 12:22:28
PHP
krispey101, 2021-06-09 12:22:28

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', 'Ярославль'));


But it always returns false, although the word Yaroslavl is in this file, what is the error? (the path to the file is correct, I checked it through include)
The site is authorized via alert login and password, maybe because of this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question