我在下面有一段,我想从中得到一个句号每个结尾的第一个词。
$paragraph="Microsoft is writing down $6.2 billion of the goodwill within its OSD. It's worth noting that at the time of the acquisition, the company recorded $5.3 billion of goodwill assigned to the OSD, bringing its total carrying balance up to $5.9 billion in September of that year. The goodwill in the OSD had climbed up to $6.4 billion by March of this year, so this accounting charge is wiping out the vast majority of that figure.";
例如,我可以做到这一点。
$sentences=explode('.',$paragraph);
print_r( $sentences);
它打印
Array ( [0] => Microsoft is writing down $6
[1] => 2 billion of the goodwill within its OSD
[2] => It's worth noting that at the time of the acquisition, the company recorded $5
[3] => 3 billion of goodwill assigned to the OSD, bringing its total carrying balance up to $5
[4] => 9 billion in September of that year
[5] => The goodwill in the OSD had climbed up to $6
[6] => 4 billion by March of this year, so this accounting charge is wiping out the vast majority of that figure
[7] => )
但是,我在徘徊如何从每个数组中获取第一个单词。例如,如何创建一个函数来获取第一个单词,如下例所示:
微软 2 它是 3 9 4
谢谢