PHP:从CSV中删除多行
我想从CSV文件中删除多行 我有一个数组(称为PHP:从CSV中删除多行,php,csv,Php,Csv,我想从CSV文件中删除多行 我有一个数组(称为$manual)设置: 我的CSV如下所示: A;3h2jhkj B;ewrwer C;fsfsdf D;adsfsdf E;sdfet F;35435345f 我删除行的代码为(不起作用): 我知道为什么它不起作用,但却无法让它发挥作用 我想要删除CSV中第一列与数组中的值匹配的所有行,以便从上面生成的CSV文件将生成: D;adsfsdf E;sdfet F;35435345f 您不需要迭代$manual,只需检查$manual中的值是否正确
$manual
)设置:
我的CSV如下所示:
A;3h2jhkj
B;ewrwer
C;fsfsdf
D;adsfsdf
E;sdfet
F;35435345f
我删除行的代码为(不起作用):
我知道为什么它不起作用,但却无法让它发挥作用
我想要删除CSV中第一列与数组中的值匹配的所有行,以便从上面生成的CSV文件将生成:
D;adsfsdf
E;sdfet
F;35435345f
您不需要迭代
$manual
,只需检查$manual
中的值是否正确即可
$table=fopen('logs/error.log','r');
$temp_table=fopen('logs/error_temp.log','wa+');
while(($data=fgetcsv($table,2048,“;”))!==FALSE){
if(在数组中($data[0],$manual,true)){
继续;
}
fputcsv($temp_table,$data);
}
fclose(表);
fclose($temp_table);
您不需要迭代$manual
,只需检查$manual
中的值
$table=fopen('logs/error.log','r');
$temp_table=fopen('logs/error_temp.log','wa+');
while(($data=fgetcsv($table,2048,“;”))!==FALSE){
if(在数组中($data[0],$manual,true)){
继续;
}
fputcsv($temp_table,$data);
}
fclose(表);
fclose($temp_table);
匹配(exect)数组中的某个东西,将匹配(exect)数组中的某个东西,将匹配(exect)数组中的某个东西,将匹配(exect)数组中的某个东西,将谢谢-我不必否定它,就像我说的,如果它在数组中,那么我不想要它…我错过了。修正。谢谢-当我把问题读出来的时候,我整理好了,但是谢谢你的回答。我不需要否定它,我会的,就像我说的,如果它在数组中,那么我不想要它…我错过了。修正。谢谢-在阅读我的问题时,我整理了一下,但是谢谢你的回答
foreach ($manual as $filename) {
$table = fopen('logs/error.log','r');
$temp_table = fopen('logs/error_temp.log','wa+');
while (($data = fgetcsv($table, 2048, ";")) !== FALSE) {
if($data[0] == $filename){
continue;
}
fputcsv($temp_table,$data);
}
fclose($table);
fclose($temp_table);
//$done = "YES";
}
D;adsfsdf
E;sdfet
F;35435345f