class iaComment
{
// Метод можно сделать static
static public function smileToSmile() {
$smiles = array(
':)' => '<img alt=":)" src="' . IA_URL . 'plugins/comments/templates/front/img/smiles/smile.png">',
'=)' => '<img alt="=)" src="' . IA_URL . 'plugins/comments/templates/front/img/smiles/smile.png">',
':(' => '<img alt=":(" src="' . IA_URL . 'plugins/comments/templates/front/img/smiles/sad.png">',
'=(' => '<img alt="=(" src="' . IA_URL . 'plugins/comments/templates/front/img/smiles/sad.png">',
':D' => '<img alt=":D" src="' . IA_URL . 'plugins/comments/templates/front/img/smiles/happy.png">',
':\'(' => '<img alt=":\'(" src="' . IA_URL . 'plugins/comments/templates/front/img/smiles/cry.png">'
);
return array(array_keys($smiles), array_values($smiles));
}
// ...
}
// Получаем массив один раз (вне цикла), чтобы каждый раз не дёргать класс
$smiles = iaComment::smileToSmile();
foreach ($comments as &$comment) {
$comment['body'] = str_replace($smiles[0], $smiles[1], $comment['body']);
}