2014-05-20 26 views
-3

我在我的网站上有一个标题部分,它输出新闻文章的标题和第一句。下面我想输出文章的其余部分减去第一段。输出php中的第一个句号后的所有内容

像这样的事情将是巨大的:

// Full Article 

$NewsArticle = "This is the article. I hope you like it."; 

// Find the First Full stop 

// Save everything after the first full stop to $NewsArticle 

$NewsArticle == "I hope you like it"; 

任何帮助将是巨大的!

感谢

亚历

+1

你甚至尝试什么吗? – Scimonster

+0

http://www.php.net/manual/en/function.substr.php加上http://www.php.net/manual/en/function.strrpos.php或爆炸,如果你不需要最后一满停止 – mplungjan

+0

是的,我一直在尝试strpos,但没有运气。以为我会问一些有用的建议。 – Alex

回答

0

试试这个

substr($NewsArticle, strpos($NewsArticle, ".")+1) 
+0

谢谢,对于新手的问题表示歉意。 – Alex

+0

不客气。没有必要道歉,我们在某些方面是新手,更重要的是要继续学习,不要怀疑有疑问时。 – user3030212

0

只需使用SUBSTR功能。

$str = "This is the article. Enjoy reading it. I hope you like it."; 
$str_res = substr($str, strpos($str, ".")+1); 
echo $str_res; 
+0

嗨,感谢您的回复 - 我真的应该对我的问题更详细,我需要它在第一个句号后输出所有内容,即使第二个字符串索引包含句号,例如: $ str = “这是文章,喜欢读它,我希望你喜欢它。”; $ str_res需要输出:“喜欢读它,我希望你喜欢它。” – Alex

相关问题