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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.