Fishcakes Posted January 26, 2022 Share Posted January 26, 2022 Hi On retrieving data from my database I use the following function to insert HTML line breaks to retain how the comment looks $CommentText= nl2br($data['CommentText']); However I'd look users to to be able to quote using the ">" character (like in reddit - so say they want to 'quote' something from a book or article) So I'm trying to wrap my head around how to do this. Would I the string for "<br>>" (to find the line break then the additional ">") and then how would I take all of the characters after the ">" to the next "<br>"? The below function is what I have started with public function Convert_Quotation($CommentText) { $FindQuote = substr($CommentText, strpos($CommentText, '<br>>') + 50); return $CommentText ; } //function end Quote Link to comment https://forums.phpfreaks.com/topic/314461-creating-a-quote-feature-for-my-site/ Share on other sites More sharing options...
maxxd Posted January 26, 2022 Share Posted January 26, 2022 Sounds like you want a Markdown library. I can't say for sure as I think I'm the one person on the planet that's not used Reddit, but `>` denotes a blockquote in most Markdown versions I've come across. If you Google it, there are many PHP libraries that can help you out. Quote Link to comment https://forums.phpfreaks.com/topic/314461-creating-a-quote-feature-for-my-site/#findComment-1593620 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.