Php 替换生成的RSS源中的文本
这是有问题的页面 我们使用的RSS生成器在“事件”提要上插入内联html标记,如Php 替换生成的RSS源中的文本,php,string,replace,rss,str-replace,Php,String,Replace,Rss,Str Replace,这是有问题的页面 我们使用的RSS生成器在“事件”提要上插入内联html标记,如、和 下面是我尝试从代码中删除这些位的代码: <div id="right" class="last"> <h1><?php esc_html_e( 'Buchanan Events', 'Fusion' ); ?></h1> <article id="jobs"> <?php if ( function_exists
、
和
下面是我尝试从代码中删除这些位的代码:
<div id="right" class="last">
<h1><?php esc_html_e( 'Buchanan Events', 'Fusion' ); ?></h1>
<article id="jobs">
<?php if ( function_exists( 'fetch_feed' ) ) { ?>
<?php include_once(ABSPATH . WPINC . '/feed.php');
$feed = fetch_feed( 'http://www.bipc.com/rssfeeds/rss.aspx?id=35' );
$feednew = str_replace( array( '<br>', '<i>', '</i>' ), '', $feed );
$limit = $feednew -> get_item_quantity(5);
$items = $feednew -> get_items(0, $limit);
if ( !$items ) {
echo "problem";
}
else {
//everything's cool
foreach( $items as $item ){ ?>
<h2 class="post"><a class="link" href="<?php echo $item -> get_permalink(); ?>" target="_blank"><?php echo $item -> get_title(); ?></a></h2>
<p class="date"><?php echo $item -> get_date( 'F j, Y' ); ?></p>
<hr>
<?php }
} ?>
<?php } ?>
</article>
</div>
我正在尝试使用str_replace()搜索
、
和
标记,并将它们替换为空,以使其余文本流动
如果我没有使用正确的方法,请告诉我。谢谢 这应该适合您: 只需使用,它将删除所有html/php标记(包括html注释)
如果你想去掉所有的html标签,只需使用strip_tags(),这就是我所修正的:
@JeffSydor这就是去掉html标签的方法。“破产”是什么意思?错误?@JeffSydor的输出是什么:var\u dump($feed)
在strip\u tags()
调用之前和之后?对不起,我不知道这是什么意思。我在$feed=strip\u tags($feed)之后添加了这个代码>我得到的只是这个:字符串(32)“4ca2a7bfd4cc1fed6a9478ba78a2f610”
$feed = strip_tags($feed);