PHP를 사용하여 하나의 열로 CSV 파일을 만듭니다. 나는 그것을 반복적으로 반복한다. 이제 원하는 것은이 CSV 안에 두 번째 열을 추가하는 것입니다. 나는 루프가 끝난 후에 그것을 원합니다. PHP로 이것을 할 수 있습니까?
for ($number = 1; $number <= 26; $number++) {
#create CSV With one column
}
#append one more column to existing CSV
다음과 같이 할 수 있습니다.
$a = file('csv.csv');// get array of lines
$new = '';
foreach($a as $line){
$line = trim($line);// remove end of line
$line .=";new column";// append new column
$new .= $line.PHP_EOL;//append end of line
}
file_put_contents('csv.csv', $new);// overwrite the same file with new data
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다