Home >Backend Development >PHP Tutorial >PHP searches whether specified data exists in csv table_PHP tutorial

PHP searches whether specified data exists in csv table_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:04:451123browse

php searches whether the specified data exists in the csv table //The principle of searching the data in Kuchang csv is to open the csv file, and then search line by line whether the specified content is included in the code we read, and if so, it returns true.

php tutorial to search whether the specified data exists in the csv table
//The principle of searching the data in Kuchang csv is to open the csv file, and then search line by line whether the specified content is included in the code we read, and if so, it returns true.

//Search for specified content in csv

$fh = @fopen("csv_file_name", "r");
if($fh) {
if(flock($fh, lock_ex)) {
While(!feof($fh)) {
            $line = fgets($fh);
If(strstr($line, $target_email_address) !== false) {
                $data = split(",", $line); // $data *is* an array
         }
}
flock($fh, lock_un);
}

fclose($fh);
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630830.htmlTechArticlephp searches whether the specified data exists in the csv table //The principle of searching for data in csv is to open the csv file and then line Line searches whether the specified content is included in the code we read, if...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn