我有一個是交給我一個CSV文件的位置後,刪除所有角色每天在年底的數據合併,我不需要這樣的:在CSV文件
"Date","Site","PCode","PName","Sales"
"2013/03/10 00:00:00","10195","66011","GT 1","9"
"2013/03/10 00:00:00","22413","66005","GT 2E","4"
"2013/03/10 00:00:00","10082","66003","GT 23E","6"
"SCode"
"12345678"
我想運行PHP腳本,它刪除所有字符,包括和之後的「SCode」。文件中的位置和文件總長度每天都在變化,因此它需要來自單詞而不是來自設置的位置。
任何想法?我看了一下,但是大多數例子在一個不同的文件不會改變的設置位置之後移除。謝謝。
這樣的新文件:
"Date","Site","PCode","PName","Sales"
"2013/03/10 00:00:00","10195","66011","GT 1","9"
"2013/03/10 00:00:00","22413","66005","GT 2E","4"
"2013/03/10 00:00:00","10082","66003","GT 23E","6"
從反饋下面都用這個感謝:
<?
$path="test.csv";
$csv = file_get_contents($path);
$new_csv = strstr($csv,'"SCode"',true); //csv file up to "SCode"
$file = fopen("test2.csv","w");
fwrite($file,$new_csv);
fclose($file);
?>
顯示一些代碼,你嘗試過或卡在..! – 2013-03-11 07:01:55