gpt4 book ai didi

php - 如何使用 PHP 动态添加 CSS 代码?

转载 作者:行者123 更新时间:2023-11-28 02:35:36 25 4
gpt4 key购买 nike

我有这个样本:

代码 PHP

<?php Zend_Debug::dump($_helper->productAttribute($_product, $_product->getDescription(), 'description')); exit; ?>

返回这个字符串

string(345) "<p>With glossy, raven-black frames, the <strong>Coleman</strong> frames command attention. With a slightly wider frame, narrow bridge, and more rounded line, you&rsquo;ll feel stylish and modern. Their bold, elegant, raven-black color is every bit the classic look. But their high style and lightweight feel hit just the right modern note.</p>

我想操作这个字符串,所以要有下面的形式:

string(345) "<p>With glossy, raven-black frames, the <strong style="font-size: echo $myvar; ">Coleman</strong> frames command attention. With a slightly wider frame, narrow bridge, and more rounded line, you&rsquo;ll feel stylish and modern. Their bold, elegant, raven-black color is every bit the classic look. But their high style and lightweight feel hit just the right modern note.</p>

基本上我想为我的 php 字符串添加 css 样式。

我怎样才能动态地做到这一点?

提前致谢!

最佳答案

假设您将字符串存储在 $str 变量中。然后:

str_replace("<strong>", "<strong style='font-size: " . $myvar . "'>", $str);

关于php - 如何使用 PHP 动态添加 CSS 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47437341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com