Jump to content

[SOLVED] trimming data from a file...


Derleek

Recommended Posts

ok, so i have generated this script to store each line from a file into an array:

 

	//retrieves file name and size form the form
$fileName = $_FILES['userfile']['name'];
$fileSize = $_FILES['userfile']['size'];
// open the file and save each line as an array entry in $content
$content = file($fileName);

// count how many lines in the file
$numLines = count($content);
//counts how many riders are in the file
$numRider = $numLines/4;
// loop through all the lines

$rstore = array();//array to store the $line variable
for ($i = 0; $i < $numLines; $i++) {
   $line = trim($content[$i])."<br>";
   $rstore[$i] = $line;
}

//declaration of arrays for storage into MySQL
$Rname = array();
$Rnum  = array();
$Rqual = array();
$Rplace= array();
//loops through and stores rider name, number, qualified, placed into each of the respective arrays with identical key's
$slot = 0;
for ($i = 0; $i<$numRider; $i++) {
	$Rname[$i] = $rstore[$slot];
	$slot++;
	$Rnum[$i]  = $rstore[$slot];
	$slot++;
	$Rqual[$i] = $rstore[$slot];
	$slot++;
	$Rplace[$i]= $rstore[$slot];
	$slot++;
	}

but for some reason it is storing return... so when i output it i get

 

line1

line2

line3

line4

 

with out entering a carriage return... i thought trim() was used to strip down returns?

Link to comment
https://forums.phpfreaks.com/topic/107696-solved-trimming-data-from-a-file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.