Good day all:

I have a textarea box in my form which receives (from a url) and display variable. The problem is that it does not translate the <br/>. instead of creating a newline where there is <br/>, it simply prints <br/>. here is an example of the output.

br/>On 11/11/10 @ 01:34<br/>We performed the following:<br/><br/>
information update<br/><br/>----End of Service Report----<br/><br/>On 11/11/10 @ 10:45<br/>We performed the following:<br/><br/>

Inside my form, the textarea is written as follows:

<td><textarea name="text" id="text" rows="26" cols="61" ><?php echo str_replace('<br/>', "\n", "$edit_servicedesc2");?></textarea>&nbsp;</td>

on other instances, the output is without the <br/>, instead, it removes the <br/> and does not replace it with newline. Something like this:

On 11/12/10 @ 11:47We performed the following:test1test2test3----End of Service Report----On 11/12/10 @ 11:24We performed the following:Information updatedOil Change performedBrake pads installed----End of Service Report...

Does anyone have any thoughts on how to resolve this issue?

Thanks
Mossa

try:

<td><textarea name="text" id="text" rows="26" cols="61" ><?php echo preg_replace('#<br\s*/?>#i', "\n", html_entity_decode($edit_servicedesc2));?></textarea>&nbsp;</td>

hielo, thanks for the reply post. Your suggested solution has worked! Thank you very much. It was successful in addressing instances where the <br> is not replaced and is simply printed.

On an instance where the output is without the <br>, and instead, it is removes and does not replace it with newline. Something like this:

On 11/12/10 @ 11:47We performed the following:test1test2test3----End of Service Report----On 11/12/10 @ 11:24We performed the following:Information updatedOil Change performedBrake pads installed----End of Service Report...

This is till an issue. As you can see from the above output where there is no spacing between words ie: "On 11/12/10 @ 11:47We performed the following:test1test2test3". This is an area where there is a new line.

do you have a link to your page? IF not, paste your page's HTML source code.

Thank you all, problem resolved.
My process may seem a bit complicated to explain as to how the issue was resolved, but let me give it shot--so that if someone else is attempt to achieve similar outcome.

I was attempting to pass variable via url. Some of the variables being passed, contained a textarea box with values retireved from db text field and displayed in the page.

The challenge was in part because I was passing the variables to multiple pages through two different link buttons.

Using the

str_replace("<br/>", "\n",

cause a wierd effect whereas; on page, the <br/> was removed and was not replaced with a newline; instead it combined everything together--like this:

On 11/12/10 @ 11:47We performed the following:test1test2test3----End of Service Report----On 11/12/10 @ 11:24We performed the following:Information updatedOil Change performedBrake pads installed----End of Service Report...


On the other page, The problem was that it did not translate the <br/>. instead of creating a newline where there is <br/>, it simply prints <br/>. something like this:

br/>On 11/11/10 @ 01:34<br/>We performed the following:<br/><br/>
information update<br/><br/>----End of Service Report----<br/><br/>On 11/11/10 @ 10:45<br/>We performed the following:<br/><br/>


The solution I determined was:

On the originating --variable passing via url-- page, I created two functions with the str_replace strings. I created two textarea boxes both receiving the same values from db (as explained above) and however, made one box hidden. In each respective box, I added the str_replace function with the following modifications:

box one:

str_replace("<br/>", "\n",...

box one:

str_replace("\n", "<br/>",...

This addressed the problem...

Thanks for all of the post in response to this help request.
Mossa

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.