Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个用 PHP 写的博客,需要缩短最新的博客文章以供首页。我在 $variable 中有最新的帖子,并且想删除第 x 个单词之后的所有文本。在每个单词之间我有一个空格,如果这有帮助的话。提前致谢!:)
implode(' ', array_slice(explode(' ', $variable), 0, x));
用您需要的单词数替换“x”。