PHP从字符串中删除p标记
使用WooCommerce for Wordpress,我创建了产品属性,并使用了一行值PHP从字符串中删除p标记,php,wordpress,woocommerce,str-replace,Php,Wordpress,Woocommerce,Str Replace,使用WooCommerce for Wordpress,我创建了产品属性,并使用了一行值作为分隔符将行拆分为,但问题是Wordpress一直在向输出添加标记 查看输出HTML,它似乎将第一个$applies[0]包装为,然后$applies[3]在它之后有。当我更希望从字符串中删除所有时 我尝试了echo stru替换(“”,“,$apply)和$applicated=preg_replace('#]*>(\s |?)*#',''$apply)但仍然没有运气 PHP <tr class="
作为分隔符将行拆分为
,但问题是Wordpress一直在向输出添加
标记
查看输出HTML,它似乎将第一个$applies[0]
包装为
,然后$applies[3]
在它之后有
。当我更希望从字符串中删除所有
时
我尝试了echo stru替换(“”,“,$apply)代码>和$applicated=preg_replace('#]*>(\s |?)*#',''$apply)代码>但仍然没有运气
PHP
<tr class="<?php if ( ( $alt = $alt * -1 ) == 1 ) echo 'alt'; ?>">
<th><?php echo $woocommerce->attribute_label( $attribute['name'] ); ?></th>
<td><?php
if ( $attribute['is_taxonomy'] ) {
$values = woocommerce_get_product_terms( $product->id, $attribute['name'], 'names' );
echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
} else {
//Convert pipes to commas and display values
$values = array_map( 'trim', explode( '|', $attribute['value'] ) );
$apply = apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
$applies = explode(";", $apply);
echo $applies[0]."</td><td>";
if ($applies[2] != ''){
echo "<font style='text-decoration:line-through'>".$applies[1]."</font></td><td>";
} else {
echo $applies[1]."</td><td>";
}
echo $applies[2]."</td><td>";
$applies3 = str_replace(' ', '', $applies[3]);
$applies3 = str_replace('<p></p>', '', $applies3);
echo $applies[3];
}
?></td>
</tr>
已更改
$apply=apply_过滤器('woocommerce_attribute',wpautop(wpTextureize(内爆(',',$values)),$attribute,$values)代码>
至
$apply=apply_过滤器('woocommerce_attribute',wptexturize(内爆(',',$values)),$attribute,$values)代码>
通过从此行中删除wpautop()
,它将删除
标记
<tr class="">
<th>Container</th>
<td><p>W2300 x D1030 x H940mm</p></td><td> £19953</td><td></td><td> in stock<p></p></td>
</tr>