• 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.

  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Serena, Kris, Dawn, Red - which Pokémon protagonist is your favorite? Let us know by voting in our grand final favorite protagonist poll!
  • PokéCommunity supports the Stop Killing Games movement. If you're a resident of the UK or EU, consider signing one of the petitions to stop publishers from destroying games. Click here for more information!
  • 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
    17
    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