这并不是最有效的方法,但应该可以做到:
function the_excerpt1($s=\'\')
{
if($s !== \'\')
{
$a = explode(\' \', $s);
array_shift($a);
array_shift($a);
array_shift($a);
$s = implode(\' \', $a);
unset($a);
}
return $s;
}
echo the_excerpt1(\'the content starts this is the excerpt\');
<小时>
Update - A more efficient way
function the_excerpt2($s=\'\')
{
if($s !== \'\')
{
$s = substr($s, (strpos($s, \' \')+1));
$s = substr($s, (strpos($s, \' \')+1));
$s = substr($s, (strpos($s, \' \')+1));
}
return $s;
}
echo the_excerpt2(\'the content starts this is the excerpt\');
<小时>
the_excerpt2()
执行速度将比
the_excerpt1()