我有一个内容html
$output = '<div class="elementor-image-box-wrapper">
<div class="elementor-image-box-content">
<h3 class="elementor-image-box-title"><a href="#">Industrial</a></h3>
<p class="elementor-image-box-description">With OT’S tailored workwear solutions, you can op for a comprehensive program that takes care of your requirements entirely or...</p>
</div>
</div>';
我使用preg_replace在段落类元素or-image-box-description中添加按钮链接
$link = '<a href="#">Read more</a>';
$output = preg_replace( '/^<p class="elementor-image-box-description">(.*)<\/p>$/', '<p class="elementor-image-box-description">$1</p>'.$link, $output );
echo $输出;
但结果不起作用
1条答案
按热度按时间p5fdfcr11#
I assume you hold all your html in $output and you want to change some parts.
I suggest another way to do it.
create a php file for your component
my-component.php:
then you can