Click to See Complete Forum and Search --> : texts as is....
daimous
01-07-2005, 05:06 AM
can anybody pls help me....
suppose i have a textarea and i inputed some text
like below...
|----------------|
| daimous |
| the |
| great!!! |
| |
| |
|----------------|
how can i display the texts exactly the same as above not like this..
output: daimous <br/>the<br/>great!!!
by the way i use the functions htmlentities cause i want to Convert all applicable characters to HTML entities so that when my user
input a text like this..
--------------------------------
i am <br> a user...
--------------------------------
it will display exactly the same as,
--------------------------------
output: i am <br> a user...
--------------------------------
not this one...
--------------------------------
i am
a user...
--------------------------------
tnx! in advance!!!!
dreamcatcher
01-07-2005, 05:32 AM
Converting line breaks might work. Do you want to re-display the data in your text area?
Try:
$text = str_replace("<br/>", "\r\n", $text);
scragar
01-07-2005, 05:32 AM
huh?
have you tried using nl2br(txt); or do you want to go in the oposite direction?
I though I understood it when I first read it but after re-reading it I'm confused as to which you want:
turn <b>txt</b> into txt on the page or the other way around?
daimous
01-07-2005, 10:17 AM
to rephrase my question..suppossing i have entered the text below to my Textarea...
---------------------
daimous <br> the
<p><b>great... this is
a text...
--------------------
and i named my TEXTAREA as message(<TEXTAREA name='message'>)
the question is..how can i display the text exactly the same as above when i try to display it to other page...in other words how can i display the text i have entered above exactly the same as it is..
hope this would help to understand my question...
page1.php
-------TEXTAREA-----------------
daimous <br> the
great!!! this <p>
a <b> text.
--------------------------------
and when i submit the form from page1.php to page2.php
i want it to display the text exactly as above.
pgae2.php
---------TEXTAREA---------------
daimous <br> the
great!!! this <p>
a <b> text.
--------------------------------
htmlspecialchars() (http://www.php.net/manual/en/function.htmlspecialchars.php) and nl2br() (http://www.php.net/manual/en/function.nl2br.php)?
the tree
01-07-2005, 11:24 AM
I think your asking two questions.
To change your users line breaks to <br/> then nl2br($str); and to change thier < and > to entities of the same thing then...
$badcode = array ('<','>');
$goodcode = array ('<','>');
str_replace ($badcode,$goodcode,$string);
NogDog
01-07-2005, 11:43 AM
Originally posted by pyro
htmlspecialchars() (http://www.php.net/manual/en/function.htmlspecialchars.php) and nl2br() (http://www.php.net/manual/en/function.nl2br.php)?
To amplify, I think what you would do is:
echo(nl2br(htmlspecialchars($message)));
daimous
01-07-2005, 05:59 PM
I used these fucntions --> nl2br(htmlentities($var_message))
though it outputed the text below exactly as it is from the Original Source...
SOurce:
-----------------------
daimous <br> the
great!!! this <p>
a <b> text.
-----------------------
output:
-----------------------
daimous <br> the<br />
great!!! this <p><br />
a <b> text.
-------------------------
but it added something like, (<br />)..how can I eliminate the (<br />) thing....pls help me...tnx! in advance!!!