如何突出显示magento中的特定字符串

How to highlight specific string in magento

在我的 phtml 中,我从数据库中获取数据

<?php $id = $this->getRequest()->getParam('id');
$question = Mage::getModel('example/question')->load($id);
$answer = Mage::getModel('example/answer')->getCollection()->addFieldToFilter('id', $id);
$i = 1;
?>
<h2><?php echo $this->__('Your Question View')?></h2>
<div class="que-view">
    <div><?php echo $this->__('<b>'.'Question:'.'</b>') . ' ' . $question->getQuestions();?></div>
    <span class='que-view-tag'><?php echo $this->__('<b>'.'Answer'.'</b>'. ' ')?></span>
    <?php foreach($answer as $ans):?>
        <p class='que-view-ans'><?php echo '<b>' .$i .')</b>'.' '.$ans->getAnswers();?></p>
        <?php $i++;?>
    <?php endforeach;?>

</div>

在上面的代码中,我使用 foreach 打印答案,现在我从数据库中获取所有答案,但在特定答案中,我想突出显示该答案。具体答案意味着我想检查客户 ID 是否相同,如果相同我想突出显示该答案如何做到这一点

O/p这样

 Que: test
    Ans: Ans1 ( customerid = 1)
       (highlight this Ans)  Ans2 ( customerid = 2)
         Ans3( customerid = 3)

使用这个括号()只是为了让你能理解

试试这个。

<p class='que-view-ans <?php if($a == $b) echo 'make-bold'; ?> '><?php echo '<b>' .$i .')</b>'.' '.$ans->getAnswers();?></p>

不要忘记为 'make-bold' class 创建样式。