How to print \\n chars

Hi guys,

How do I print a string submitted from a textarea that shows hidden chars such as \
etc

Thanks in advance

Crabby

Hi cups

At the moment I just want to display any hidden characters for test purposes

Crabby

If you are displaying it as html can you just wrap it in <pre></pre> tags?

I think it depends what you plan to do with it, store it, display it etc.

Enclose the string in ’ instead of " and then the only escape character it will convert is \’ and all the others will print exactly as entered.

But, you’re right I think that’s the only way it’s going to work

Thanks for your reply

That’s basically what I’m doing already in order to break up the text and format the values.

But I was just curious whether there was a php function that exposed these hidden characters, for example, is a new line in a cell value different to a new line at the end of a row?

When you paste the content from word/excel then are those characters visible in the textarea? I think no. You can just trap them in PHP with some functions like strpos or str_replace like. So what do you want to do with them?


$text = str_replace("\
" "NEWLINE", $text);
$text = str_replace("\	" "TAB", $text);

Does this make sense?

Hi RNEL

Thanks for your reply.

Part of my appication allows users to copy and paste data from Excel and I want to be able to identify any hidden characters that exist, IE
, \ , \r etc

Thanks again

Crabby


nl2br();

http://www.php.net/nl2br