에 "문제"CSV를 구문 분석하는 방법은 "문제"CSV는 다음과 같이 파일을 구문 분석했습니다 :PHP
물론some text here
other line of text, here
header1, header2, header3
value1, value2, value3 // data row #1
value1, value2, value3 // data row #2
(empty line)
(empty line)
some other text here
내가 행 (값 1, 값 및 VALUE3)에만 관심이 있어요 실제로 가치있는 데이터가 포함되어 있습니다. 나는 문자열로 URL을 가져오고보다 것은 str_getcsv
(기본 매개 변수)를 호출하지만 내가 갖는 것이 작업하기 어려운 배열입니다하려고했습니다 :
array
0 => string 'some text here ' (length=50)
1 => string ' other text here
other text here
header1 ' (length=50)
2 => string 'header2' (length=13)
3 => string 'header3' (length=14)
4 => string 'header4' (length=14)
5 => string '
value1' (length=2)
6 => string 'value2' (length=1)
7 => string 'value3' (length=1)
8 => string 'value4
올바른 CSV 파일이 아닙니다. fgetcsv를 사용하기 전에 문제를 해결해야합니다 (즉, 잘못된 행을 제거해야합니다). – ThiefMaster
@ ThiefMaster 알아. 내가 처음과 2 행을 건너 뛰어야한다고 생각하니? – gremo