Search for specified data in a csv table in php _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Php searches for the specified data in a csv table. In php, you can search for the csv table to see if the specified data exists. in csv, the principle is to open the csv file, and then search for the specified content in one row to see if it is included in the code, if the php search csv table contains the specified data, // The principle of searching for the csv data is to open the csv file, and then search for the specified content in one row to see if it is included in the code, true is returned.

Search for specified data in a csv table in the php Tutorial
// The principle of searching for csv data is to open the csv file and search for whether the specified content is included in the code in one row. If yes, true is returned.

// 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 );
}

...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.