Hi there,
I am currently facing some problems with return carriages.
I have an address already in a table in the database which has return carriages.
Now when you echo the address out it will loose the return carriages and instead will put it all on one line.

I have tested it by copying and pasting the original address from the db to Microsoft Word which shows that there are return carriages and displays on each line. However when you copy and past the address echoed out on the page into word, it does not show any symbols for return carriages and displays on one line.

I have tried creating functions like below which also does not work!

function rcarriage($string){
$string = str_replace(chr(13),"<br/>",$string);
return $string;
}

The 'chr(13)' means its a return carriage.

My understanding to this problem is it may lose return carriages upon fetching it back to the page??

I have also tested the address in a textarea box and it will display on each line as it suppose to.

I hope someone can help!

Thanks

Jat

$string= nl2br($string);

If above fails, try this:

function rcarriage($string){
         $string = str_replace("\n","\n<br>", $string);
          return $string;
      }

Hi,

nl2br worked!
The only small issue was that I had to apply it to the actual row e.g. nl2br($row) and could not get it to work from within a variable e.g. $add = nl2br($row). God know's why!

Thanks guys

mark it solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.