Forum Moderators: coopster
--
$tmp_name = $_FILES['csv']['tmp_name'];
$handle = fopen($tmp_name, "r");
while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) { print_r($data); }
--
prints out something like this when using a tab delimited .csv file
D�e�s�c�r�i�p�t�i�o�n� �L�i�n�e� �1�
D�e�s�c�r�i�p�t�i�o�n� �L�i�n�e� �2�
D�i�s�p�l�a�y� �U�R�L�
D�e�s�t�i�n�a�t�i�o�n� �U�R�L�
C�a�m�p�a�i�g�n� �S�t�a�t�u�s�
--
when using commas for the delimits, in a .csv file it prints out normal like this:
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { print_r($data); }
Description Line 1
Description Line 2
Display URL
Destination URL
Campaign Status
---
Why is is messing up so much when I insert a tab delimited CSV, I can't seem to figure it out for the life of me, and I've searched all over!
$handle = fopen($tmp_name, "rb");
cleanString($text); returns cleared out string:
function cleanString( $string = "" ) {
$allowedCharacters= array( " ", "a", "b", "c", "d", "e", "g", "h", "i", "j",
"k", "l", "m", "n", "o", "p", "q", "r", "s",
"t", "u", "v", "w", "x", "y", "z",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
"‘", "’", "‚", "“",
"”",
"„",
"†",
"‡",
"‰",
"‹",
"›",
"♠",
"♣",
"♥",
"♦",
"★",
"☆",
"‾",
"←",
"↑",
"→",
"↓",
"™",
"!",
"\"",
"#",
"$",
"%",
"&",
"'",
"(",
")",
"*",
"+",
",",
"-",
".",
"/",
":",
";",
"<",
"=",
">",
"?",
"@",
"[",
"\\",
"]",
"^",
"_",
"`",
"{",
"¦",
"}",
"~",
"–",
"—",
"¡",
"¢",
"£",
"¤",
"¥",
"¦",
"§",
"¨",
"©",
"ª",
"«",
"¬",
"",
"®",
"¯",
"°",
"±",
"²",
"³",
"´",
"µ",
"¶",
"·",
"¸",
"¹",
"º",
"»",
"¼",
"½",
"¾",
"¿",
"À",
"Á",
"Â",
"Ã",
"Ä",
"Å",
"Æ",
"Ç",
"È",
"É",
"Ê",
"Ë",
"Ì",
"Í",
"Î",
"Ï",
"Ð",
"Ñ",
"Ò",
"Ó",
"Ô",
"Õ",
"Ö",
"×",
"Ø",
"Ù",
"Ú",
"Û",
"Ü",
"Ý",
"Þ",
"ß",
"à",
"á",
"â",
"ã",
"ä",
"å",
"æ",
"ç",
"è",
"é",
"ê",
"ë",
"ì",
"í",
"î",
"ï",
"ð",
"ñ",
"ò",
"ó",
"ô",
"õ",
"ö",
"÷",
"ø",
"ù",
"ú",
"û",
"ü",
"ý",
"þ",
"ÿ" );
$newString .= "";
for( $incString = 0; $incString < strlen( $string ); $incString++ ) {
if( in_array( strtolower( $string[$incString] ), $allowedCharacters ) ) {
$newString .= $string[$incString];
}
}
return $newString;
}