I have a script that uploads a tab-delimited .txt file (addresses), moves a copy to a file on my server and writes a new, edited file that removes duplicate entries, removes " " from fields, and combines two fields (Address 1 & Address 2).
For some reason, it works perfectly every time when I test it at home on my PC. BUT, when I run the same script from the same server using the same .txt file at work with a Mac it doesn't work.
It does upload and move the file without a hitch. However, when it writes the new edited file it doesn't remove the duplicates, remove the " " or combine the fields. It just makes a copy of the uploaded file.
This totally baffles me as it was my newbie impression that PHP did all of its magic on the server side.
So what am I doing wrong?
Here's the part of the script that edits the file:
(NOTE- the .txt file is sorted so duplicates are always adjacent)
if ($New) { // BEGIN $New IF STATEMENT
$n=1;
$Cnt=count($Data);
while ($n<$Cnt) { // BEGIN WHILE STATEMENT
$p=$n-1;
if ($Data[$n]==$Data[$p]) { // Check for duplicate
$n++;
} else { // If not a duplicate, clean up and write to file
$Get=explode("\t",$Data[$n]);
$x=0;
while ($x<8) {
$Get[$x]=trim($Get[$x],"\x22"); // remove quotes
$x++;
}
$Move=$Get[3];
$Get[3]="";
fwrite($New,"$Get[0]\t$Get[1]\t$Get[2] $Move\t$Get[3]\t$Get[4]\t$Get[5]\t$Get[6]\t$Get[7]");
$n++;
}
} // END WHILE STATEMENT
} // END $New IF STATEMENT