shimano55 Posted April 23, 2006 Share Posted April 23, 2006 Hey everyone. I'm building a CMS and am working on the formatting of news posts. I have nl2br() to add breaks to the result, but I'm at a loss when it comes to indents. When I submit the news post, I use 5 spaces at the beginning, and I can see 5 spaces in the field on phpmyadmin. But when the result is displayed on the site, there are only the spaces in between words and sentences. No indent.This is my current format function:[code]function newsPost($post) { return nl2br(htmlspecialchars($post)); }[/code]What do I have to add to it to get the ident spaces to show?Thanks in advance,shimano55 Quote Link to comment Share on other sites More sharing options...
bbaker Posted April 24, 2006 Share Posted April 24, 2006 are you using " " or just pressing the space bar? If pressing the space bar, your browser will ignore the "whitespace" of the spaces. ORyou can do it correctly & use CSS to do your indents. :)[code]p{ text-indent: 10px}[/code]will indent the first line. Quote Link to comment Share on other sites More sharing options...
shimano55 Posted April 24, 2006 Author Share Posted April 24, 2006 @css: Yes, but what if the news post has more than one paragraph?I'm making an admincp for the news posts. So I need it to be by just hitting the spacebar. As I said, the spaces are there in phpmyadmin. Is there no other way to accomplish this?Thanks,shimano55 Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 24, 2006 Share Posted April 24, 2006 Change your function to the following:[code]function newsPost($post){ $post = nl2br(htmlspecialchars($post)); //convert two spaces into " " this will force the browser to not ignore the spaces $post = str_replace(" ", " ", $post); return $post;}[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.