• Please note that this section is for questions regarding the forum itself - it is not for fan game-related questions. If you have a question about a fan game, ask in the appropriate thread.

  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Conquest protagonist in the poll by clicking here.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Suggestion: strip bbcodes from last post bit on forum display

-GiЯ

Banned
  • 119
    Posts
    16
    Years
    • Age 33
    • G IR
    • Earth
    • Seen Nov 30, 2023
    Sometimes in the lastpost bit on forumdisplay you may notice odd strings due to bbcode, the following replace will strip all bbcode from the lastpost bit.
    Code:
    $LastPostVar = preg_replace('~\[(img|url|code|h2|span|div|and|any|other|codes|to|omit)\b[^]]*](.*?)\[/\1]~is', '', $LastPostVar);

    Another way to go about this would be using replaces for each bbcode, this would allow users to see there is something there, but they must open the thread to see the full content:
    Code:
    $find = ['/\[img\](.*)\[\/img\]/im', '/\[url.*\](.*)\[\/url\]/im'];
    $replace = ['*IMAGE*', '*LINK*'];
    
    $LastPostVar = preg_replace($find, $replace, $LastPostVar);
     
    Last edited:
    Back
    Top