dsfsad089111 2013-03-03 13:51
浏览 12
已采纳

从对象数组中获取值并在使用之前修改它的内容

Sorry i don't know under which keywords i should find the answer, but here is the problem:

There is a $data->cart_show;, while doing var_dump() on it, i get this values:

string '<a style ="float:right;" href="/index.php?option=com_virtuemart&amp;view=cart&amp;Itemid=105&amp;lang=en">Cart content</a>' (length=124)

I need to remove style attribute and add a custom class on it, (i need to do it in a view file and not in a controller or model) so it becomes like this:

<a href="#SameURL" class="customClass">Cart content</a>

Thanks for any tips

  • 写回答

1条回答 默认 最新

  • doubao6936 2013-03-03 14:16
    关注

    Things like this must be done in model, controllers or in view helpers. Such logic shouldn't be in a view itself. But what you want could be done in two ways:

    1) Use a regular expression and replace your 'style' attribute by a 'class' with preg_replace() function

    2) Use DOMDocument to modify your existing element

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 vue3 + vite + electron打包找不到第三方包?
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥50 vue组件中无法正确接收并处理axios请求
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 MATLAB联合adams仿真卡死如何解决(代码模型无问题)
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决
  • ¥15 python中transformers可以正常下载,但是没有办法使用pipeline
  • ¥50 分布式追踪trace异常问题
  • ¥15 人在外地出差,速帮一点点