HHawk Posted March 3, 2009 Share Posted March 3, 2009 The original creator of this small PHP script stopped working on it and I don't know much about PHP, so I need some help. Here is the script: <?php $fourcolor = 0; function pokerhand($text) { // Only take things that are between the tag. $ret = preg_replace("'<pokerhand>(\w*)</pokerhand>'e", "replace_card('\\1')", $text); return $ret; } function replace_card($text) { $ret = ""; $a = preg_split('//', $text, -1, PREG_SPLIT_NO_EMPTY); foreach($a as $value) { if(!strcmp($value, "c")) { $ret .= '<span class="clubs">♣ </span>';; } else if(!strcmp($value, "d")) { $ret .= '<span class="diamonds">♦ </span>'; } else if(!strcmp($value, "h")) { $ret .= '<span class="hearts">♥ </span>'; } else if(!strcmp($value, "s")) { $ret .= '<span class="spades">♠ </span>'; } else { $ret .= $value; } } return($ret); } function pokerhand_head() { global $fourcolor; $diamond = $fourcolor ? "blue" : "red"; $club = $fourcolor ? "green" : "black"; echo " <style type='text/css'> .diamonds { color: ".$diamond."; font-size: 15px; } .clubs { color: ".$club."; font-size: 15px; } .hearts { color: red; font-size: 15px; } .spades { color: black; font-size: 15px; } </style> "; } add_filter('the_content', 'pokerhand'); add_filter('the_excerpt', 'pokerhand'); add_filter('comment_text', 'pokerhand'); add_action('wp_head', 'pokerhand_head'); ?> As you can see it's a wordpress plugin script. The script itself works without problems, however it doesn't "color" the first number/graphic in front of the spade, diamond, heart or club. Sorry for my bad english, but I dunno how to describe it better. Maybe an example will help. Example When you use: <pokerhand>Js3h</pokerhand> It will show this: J♠ 3♥ But I want it to show like this: J♠ 3♥ As you can see, the number in front of the 3 is also colored red (of course the same goes for diamonds). And if possible, I want the output to be bold. Please help. Thanks! Quote Link to comment Share on other sites More sharing options...
HHawk Posted March 3, 2009 Author Share Posted March 3, 2009 Nevermind. Got fixed on another forum. Quote Link to comment 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.