I am changing certain text to images that fall within these brackets [ ].
THe problem i am having is that sometime it will replace the text and sometimes it won't, also it is changing the text that matches even if it isn't within the brackets.
How can i fix this to work how it needs to.
Code:
$cards = array('2','3','4','5','6','7','8','9','T','J','Q','K','A');
$suits = array ('c','d','h','s');
$fromArray = $toArray = array();
foreach($cards as $card) {
foreach($suits as $suit) {
$word[] = '['.$card.$suit;
$word[] = $card.$suit.']';
$word[] = ' '.$card.$suit.' ';
$link[] = '[<img src="http://mypokerrails.com/forum1/cards/'.$card.$suit.'.png">';
$link[] = '<img src="http://mypokerrails.com/forum1/cards/'.$card.$suit.'.png">]';
$link[] = '<img src="http://mypokerrails.com/forum1/cards/'.$card.$suit.'.png">';
}
}
$this->post['message'] = str_ireplace($word, $link, $this->post['message']);