Jump to content

PHP - BBCode - Checking for blank posts?


citricsquid

Recommended Posts

Hi guys,

 

I've built my own mini BBCode to use with an application, using preg_replace to create the replacements of [][/] that match my array of BBCode samples. I also validate inputs, checking that they're not empty or have too little characters. However, I have hit a problem:

 

If a does something like [ b ][ / b ] (no spaces) it counts towards the total character count, even though it's output is nothing, therefore even if the min character count is 100, just having 20 [ b ][ / b ]'s would go over that and still be blank.

 

How can I remove any BBCode from my string, where it contains nothing inside? I'm thinking I'll need to use preg_replace, like, trim all whitespace from the string and check if [ b ][ / b ] (remove spaces) is there, if it is, remove it.

 

Is this the correct method, or have I made an oversight? :)

 

:-*

Link to comment
https://forums.phpfreaks.com/topic/156253-php-bbcode-checking-for-blank-posts/
Share on other sites

Why write it? http://be.php.net/bbcode

 

I've looked at that, but after installing it it doesn't work. Dunno what the problem is, I'm probably doing something wrong, but right now I just want something that works and this pretty much does, so I'm not changing.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.