首页 > 开发 > PHP > 正文

php搜索csv表格中是否存在指定数据

2024-05-04 21:59:08
字体:
来源:转载
供稿:网友

php搜索csv中的数据原理是打开csv文件,然后一行行搜索指定的内容是否包含在我们读取这代码中,如果是返回true,搜索csv中指定内容,代码如下:

  1. $fh = @fopen("csv_file_name""r"); 
  2. if($fh) { 
  3.    if(flock($fh, lock_ex)) { 
  4.       while(!feof($fh)) { 
  5.          $line = fgets($fh); 
  6.          if(strstr($line$target_email_address) !== false) { 
  7.             $data = split(","$line); // $data *is* an array 
  8.          }//开源代码Vevb.com 
  9.       } 
  10.       flock($fh, lock_un); 
  11.    } 
  12.    fclose($fh); 
  13. }

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表