nrg_alpha Posted September 28, 2009 Share Posted September 28, 2009 I was dumping a code snippet into a regex thread (this one to be exact)... here is a slight variation of the snippet (got rid of a redundant non-capturing group and outputted using nl2br function.. otherwise, pretty much the same code) using code bbc tags: $text = <<<EOF Dealt to Ceewyl [8s Jd Jc] [4d] Dealt to art of ace [6h 9h 9c] [Kd][Kg] EOF; function graphicCards($cardAbbreviations){ $arr = preg_split('#[\[\]\s]#', $cardAbbreviations[0], -1, PREG_SPLIT_NO_EMPTY); $image = ''; foreach($arr as $val){ $image .= "<img src='http://mypokerrails.com/forum1/cards/$val.png'>"; } return $image; } $text = preg_replace_callback('#\[(??:[2-9TJQKA]|10)[cdhs]\s?)+\]#', 'graphicCards', $text); echo nl2br($text); Now in that regex thread, if I use ... instead of the code tags, after a few seconds in the post preview window, I noticed this issue: In chrome, this was added at the top of the page as well: Seems like something about the preg statements caused some parsing issues.. When I test the above snippet in this post (using only php bcc tags), it seems to format correctly (without these preview issues): $text = <<<EOF Dealt to Ceewyl [8s Jd Jc] [4d] Dealt to art of ace [6h 9h 9c] [Kd][Kg] EOF; function graphicCards($cardAbbreviations){ $arr = preg_split('#[\[\]\s]#', $cardAbbreviations[0], -1, PREG_SPLIT_NO_EMPTY); $image = ''; foreach($arr as $val){ $image .= "<img src='http://mypokerrails.com/forum1/cards/$val.png'>"; } return $image; } $text = preg_replace_callback('#\[(??:[2-9TJQKA]|10)[cdhs]\s?)+\]#', 'graphicCards', $text); echo nl2br($text); Why would it format correctly here yet not in the regex thread? Is this a SMF issue, or is it something here on the freaks? EDIT - Interesting, that snippet did display correctly in the post preview of this post, but when posted, it breaks as well.. hmmm Quote Link to comment https://forums.phpfreaks.com/topic/175872-php-bbc-tag-issues/ Share on other sites More sharing options...
Daniel0 Posted September 29, 2009 Share Posted September 29, 2009 Sorry about that. It was my fault. Fixed. Quote Link to comment https://forums.phpfreaks.com/topic/175872-php-bbc-tag-issues/#findComment-926902 Share on other sites More sharing options...
nrg_alpha Posted September 29, 2009 Author Share Posted September 29, 2009 Thanks Dan.. I later noticed one way to remedy this issue was to use code tags, and simply use <?php ... ?> inside it. Quote Link to comment https://forums.phpfreaks.com/topic/175872-php-bbc-tag-issues/#findComment-927008 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.