last bit of help ....

From: Date: Sun, 26 Aug 2001 01:13:37 +0000
Subject: last bit of help ....
Groups: php.general 
Request: Send a blank email to php-general+get-64466@lists.php.net to get a copy of this message
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 array1.php <? // Mail text file extractor. // Written to extract out certain parts of the file and output in a csv friendly format. // Dan McCullough include("functions.php"); 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"; } exit;} } ?> <html> <head> <title>Extractor</title> </head> <body> <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"> </form> </body> </html> function.php 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 touch($newfilename); chmod($filename,0777); chmod($newfilename,0777); $command = "cat /home/sites/projects/web/extractor/$file_name | egrep 'State:|Name:|Address:|City:|e-mail:|Zip:'>$filename"; system($command); ## nothing worked for me until I added this next line. system("exit(0)"); } return $tmp_file_name; return $new_file_name; } ?> anythoughts would be appreaciated dan ===== 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 http://phonecard.yahoo.com/

« previous php.general (#64466) next »