我有这个样本:
代码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’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’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样式。
我该如何动态地执行此操作?
提前谢谢!
答案 0 :(得分:0)
让我们假设您将字符串存储在$ str变量中。然后:
str_replace("<strong>", "<strong style='font-size: " . $myvar . "'>", $str);