Removing New line character in Fields PHP
Posted
by Aruna
on Stack Overflow
See other posts from Stack Overflow
or by Aruna
Published on 2010-03-16T04:41:54Z
Indexed on
2010/03/16
5:06 UTC
Read the original article
Hit count: 450
Hi,
i am trying to upload an excel file and to store its contents in the Mysql database.
i am having a problem in saving the contents.. like
My csv file is in the form of
"1","aruna","IEEE paper" "2","nisha","JOurnal magazine"
actually i am having 2 records and i am using the code
<?php
$string = file_get_contents( $_FILES["file"]["tmp_name"] );
//echo $string;
foreach ( explode( "\n", $string ) as $userString )
{
echo $userString;
}
?> since in the Csv record there is a new line inserted in between IEEE and paper it is dispaying me as 3 records..
How to remove this new line code wise and to modify the code so that only the new line between the records 1 and 2 is considered... Pls help me....
© Stack Overflow or respective owner