Jump to content

Recommended Posts

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:

 

broken_php_tags-02.gif

 

In chrome, this was added at the top of the page as well:

 

broken_php_tags-01.gif

 

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

Link to comment
https://forums.phpfreaks.com/topic/175872-php-bbc-tag-issues/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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