PHP - how to delete a row from CSV file ?
2 posts
Page 1 of 1
I want to delete a row from a CSV file, but I figured its not that simple... Can anyone make a function using this prototype ? :
Code: Select all
TYVM !!function delline($file,$str);
You could try
Code: Select all
all of the return false; bits aren't needed and can be removed, it just makes the code more standardised with the PHP stuff.function delline($file,$str){
if(!$fp = fopen($file,"w+")){
return false;
}
if(!$cont = fread($fp)){
return false;
}
$cont = str_replace($str."\r\n","",$cont);
if(!fwrite($fp,$cont)){
return false;
}
if(!fclose($fp)){
return false;
}
return true;
}
2 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023