替换 table 中的字符串

replace string in the table

如果属性等于 "Destaque:",我必须检查一个字符串并替换,如果属性匹配它无法打印该行,但我对函数感到困惑,有人可以帮忙吗我?

<?php

class Produto_Atributo
{
    function __construct()
    {
    }


    function produtoAtributo($codigo)
    {
        Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

        $banco_magento = Mage::getSingleton('core/resource')->getConnection('core_write');


        $sql = "SELECT * FROM tw_produto_atributo where entity_id=" . $codigo;


        $resultadoSql = $banco_magento->fetchAll($sql);

        $count = 0;

        foreach ($resultadoSql as $linha) {

            $classe = '';

            if ($count % 2 == 0) {
                $classe = 'par';
            }
            else {
                $classe = 'impar';
            }

            $_atributo = $this->recuperarAtributo($linha['attribute_id']);


            $_optionText = $this->recuperarOptionid($_atributo, $linha['option_id']);
            $descricao=$linha['ds_conteudo'] ;
            $order   = array("\n");
            $replace = '<br />';
            $newstr = str_replace($order, $replace, $descricao);


            if (isset($linha['ds_conteudo']) && $linha['ds_conteudo'] != '') {
                echo '<tr class="active '.$classe.'">

                <td class="table-caracteristica-titulo" style="padding-left: 45px !important;padding-right: 45px !important; "> ' .  ucwords( strtolower($_optionText)) . '</td>

                <td class="table-caracteristica-descricao" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $newstr. '</td>
            </tr>';
            } else {
                echo '<tr class="'.$classe.'">
                <td  class="table-caracteristica-titulo" style="padding-left: 45px !important;padding-right: 45px !important;">'if($_atributo->getFrontend_label()==!"Destaque:"){$_atributo->getFrontend_label();}else {'Loko'.$_atributo->getFrontend_label();} '</td>

                <td class="table-caracteristica-descricao" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $_optionText . '</td>
                </tr>';
            }

            $count = $count + 1;

        }
    }

    function recuperarAtributo($atributo)
    {

        $cod = $atributo;

        $attr = Mage::getModel('eav/entity_attribute')->getCollection()->addFieldToFilter('attribute_id', array('eq' => $cod))->getFirstItem();

        return $attr;

    }

    function recuperarOptionid($atributo, $option_id)
    {

        return ($atributo->getSource()->getOptionText($option_id));

    }
}

已经收到了哈哈 非常简单,答案如下:

  if (isset($linha['ds_conteudo']) && $linha['ds_conteudo'] != '') {
                echo '<tr class="active '.$classe.'">

                <td class="table-caracteristica-titulo" style="padding-left: 45px !important;padding-right: 45px !important; "> ' .  ucwords( strtolower($_optionText)) . '</td>

                <td class="table-caracteristica-descricao" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $newstr. '</td>
            </tr>';
            } else {
                if($_atributo->getFrontend_label()<>"Destaque:"){
                    echo '<tr class="'.$classe.'">
                        <td  class="table-caracteristica-titulo" style="padding-left: 45px !important;padding-right: 45px !important;">' . $_atributo->getFrontend_label() . '</td>

                        <td class="table-caracteristica-descricao" style="padding-left: 45px !important;padding-right: 45px !important;"> ' . $_optionText . '</td>
                        </tr>';
                }

            }