aha. . . however, it's still giving me an error, I have a feeling it might have to do with the path to the file : Warning: file("") - Inappropriate ioctl for device in /home/domain/public_html/scripts/script3.php on line 15
Here's the script I used :
<?php
// Get the data from the original file
$sFilename="/home/domain/public_html/scripts/azd.txt";
//This will split up the file so each line is a row in the array
$aOrigFile = file($sFileName);
// Open the new file
// "a" for append, write-only
$fp = fopen("/home/domain/public_html/scripts/adf.txt", "a");
// Set the field numbers you want to keep in an array, makes it easier
later on
$aFields = array(3,5,7);
// Loop through the file rows
for($x = 0; $x < count($aOrigFile); $x++) {
// Explode the line into an array using | as a delimiter.
// We use trim to strip the newline character at the end
$aLine = explode("|",trim($aOrigFile[$x]));
foreach($aFields as $v) {
// Write the fields you want to a new variable
$sNewLine .= ($sNewLine =="") ? $aLine[$v] : "|".$aLine[$v];
}
// Add the newline character to the end of the string
$sNewLine .= "\n";
// Write the new line to the new file
fwrite($fp, $sNewLine);
// Clear the new line variable
unset($sNewLine);
}
// Close the new file
fclose($fp);
?>
whadya think?