Evil Penguin Posted January 9, 2009 Share Posted January 9, 2009 hi how do you replace a enter with php because when it retrives a post from the database and echo's it on the page it removes all the enters e.g. this is a post in the database but when its echoed onto the page it does this this is a post in the database Link to comment https://www.neowin.net/forum/topic/719784-php-replace-a-enter-with-br/ Share on other sites More sharing options...
0 Brian M. Veteran Posted January 9, 2009 Veteran Share Posted January 9, 2009 http://uk2.php.net/nl2br Link to comment https://www.neowin.net/forum/topic/719784-php-replace-a-enter-with-br/#findComment-590392452 Share on other sites More sharing options...
0 Evil Penguin Posted January 9, 2009 Author Share Posted January 9, 2009 i've already tried that and it didn't work because i have code in it aswell echo nl2br(" <div align='center'> $post </div> "); all it does is display nothing on the page Link to comment https://www.neowin.net/forum/topic/719784-php-replace-a-enter-with-br/#findComment-590392544 Share on other sites More sharing options...
0 Brian M. Veteran Posted January 9, 2009 Veteran Share Posted January 9, 2009 i've already tried that and it didn't work because i have code in it aswellecho nl2br(" <div align='center'> $post </div> "); all it does is display nothing on the page if $post is a variable, then: echo "<div align='center'>" . nl2br($post) . "</div>"; or even better, there's no need to store the div in the variable, or even parse it with php - e.g: <div align="center"> <?php echo nl2br($post); ?> </div> If that's not what you mean, pastebin the source and we'll have a look (**** any passwords out obviously). Link to comment https://www.neowin.net/forum/topic/719784-php-replace-a-enter-with-br/#findComment-590392562 Share on other sites More sharing options...
0 AnthonySterling Posted January 9, 2009 Share Posted January 9, 2009 echo '<div align="center">' . nl2br($post) . '</div>'; Link to comment https://www.neowin.net/forum/topic/719784-php-replace-a-enter-with-br/#findComment-590392568 Share on other sites More sharing options...
Question
Evil Penguin
hi how do you replace
a
enter
with
php
because when it retrives a post from the database and echo's it on the page it removes all the enters e.g.
this
is a
post in the
database
but when its echoed onto the page it does this
this is a post in the database
Link to comment
https://www.neowin.net/forum/topic/719784-php-replace-a-enter-with-br/Share on other sites
4 answers to this question
Recommended Posts