-4
  $MyString=
    "Is post each that just leaf no. He connection interested so we an sympathize advantages. To said is it shed want 

    Tiled say decay spoil now walls meant house. My mr interest thoughts screened of outweigh removing. Evening society musical besides inhabit ye my.

    Oh acceptance apartments up sympathize astonished delightful. Waiting him new lasting towards. Continuing melancholy especially so to. 
    ";

预期结果

Line1:是每个刚刚叶号的帖子。他连接感兴趣,所以我们有一个同情的优势。要说是它摆脱想要

Line2:瓷砖说腐朽现在墙壁意味着房子。我的先生感兴趣的想法被过滤掉了。晚会音乐剧除了住在你们我的。

Line3:哦接受公寓上去同情惊讶愉快。等待着他新的持久走向。持续的忧郁尤其如此。

我尝试使用preg_split('/^$/m',$mystring)但没有用

4

1 回答 1

0

您对 preg_split 的尝试应该工作得很好,这会将您的字符串分成 3 部分,但是,您仍然会有额外的空格。

您可以修剪数组的所有元素来解决这个问题。

array_map('trim', preg_split('/^$/m', $MyString));
于 2018-07-08T23:15:20.760 回答