I need to output an array to a text file, now I have created the text file now I just 
need to
write to it, well I need to get the output of the browser to this text file.  HOw can 
i do this,
oh and return each line ...

heres the code

that gets the output

// Mail text file extractor.
// Written to extract out certain parts of the file and output in a csv friendly 
// Dan McCullough


if ($submit) {
        $extract = eXtractor1($file_name,$tmp_file_name,$new_file_name);

if ($extract) {

//here goes, get the parsed file from the output of the grep command.
//read the file and output
$fcontents =  file("/tmp/$tmp_file_name", "r");

// run this funtion to format and display the file in a certain output.
function GetField($offset)
   global $fcontents;
   global $new_file_name;
   return  trim(substr($fcontents[$offset], strpos($fcontents[$offset], 
" ")));

for($i = 0, $count = sizeof($fcontents); $i < $count; $i += 6)
   // Make the numbers 1-6 constants if desired
   echo GetField($i + 1) . "," .
        GetField($i + 2) . "," .
        GetField($i + 3) . "," .
        GetField($i)     . "," .
        GetField($i + 5) . "," .
        GetField($i + 4) . ",yes<br>\n";

<form method="post" action="<? echo $PHP_SELF; ?>">
Please input the name of the text file.<br><br>
File to extract:  <input type="text" name="file_name"><br>
Temp file name:  <input type="text" name="tmp_file_name"><br>
CSV File Name:  <input type="text" name="new_file_name"><br>
<input type="submit" name="submit" value="submit">

function eXtractor1($file_name,$tmp_file_name,$new_file_name) 
global $file_name;
global $tmp_file_name;
global $new_file_name;

$filename = "/tmp/$tmp_file_name";
$newfilename = "/tmp/$new_file_name";

if (!file_exists($filename)) { 
touch($filename); // Create blank file

$command = "cat /home/sites/projects/web/extractor/$file_name | egrep
## nothing worked for me until I added this next line. 
return $tmp_file_name;
return $new_file_name;


anythoughts would be appreaciated


Dan McCullough
"Theres no such thing as a problem unless the servers are on fire!"
h: 603.444.9808
w: McCullough Family
w: At Work

Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to