Home > Article > Backend Development > PHP searches whether specified data exists in csv table_PHP tutorial
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);
}