本文共 554 字,大约阅读时间需要 1 分钟。
function stripmore($in)
{
list($p1,$p2) = explode("read_more()",$in,2);
$pass1 = preg_replace("~>[^<>]+
$pass2 = preg_replace("~^[^<>]+~","",$pass1);
$pass3 = null;
while ( $pass3 != $pass2 )
{
if ( $pass3 !== null ) $pass2 = $pass3;
$pass3 = preg_replace("~]+)>\\1>~","",$pass2);
}
return $p1."read_more()".$pass3;
}
这会删除read_more()标记之后的任何非html,并通过剥离相应的标记将其减少到最小值,同时保持任何标记在标记之前和结束之后开始:
Some text here. read_more()
==>
Some text here. read_more()
Some text read_more() here.
==>
Some text read_more()
Some text read_more() here.
==>
Some text read_more()
转载地址:http://jqkfs.baihongyu.com/