我想出了从代码中提取第一句话的代码。但是,我需要提取前两句话,我不知道该怎么做。有任何想法吗?使用PHP提取前2个句子
$input = get_field('fl_description');
$pos = strpos($input, '.' , 1);
$output = substr($input, 0, $pos+1);
echo $output;
我想出了从代码中提取第一句话的代码。但是,我需要提取前两句话,我不知道该怎么做。有任何想法吗?使用PHP提取前2个句子
$input = get_field('fl_description');
$pos = strpos($input, '.' , 1);
$output = substr($input, 0, $pos+1);
echo $output;
$input = get_field('fl_description');
$pos = strpos($input, '.' , 1);
$pos = strpos($input, '.' , $pos+1);
$output = substr($input, 0, $pos+1);
echo $output; '
尝试使用具有分隔符“。”的爆炸方法。将限制设置为2,将创建包含2个元素的数组,并带有前2个句子。
$ arrayOfSentences = explode('。',$ input,2);
echo $ arrayOfSentences [0] +“”+ $ arrayOfSentences [1];
这个工程..是它便宜? – 2013-04-10 18:52:39