以下に段落がありますが、そこから欲しいのは、ピリオドの終わりごとの最初の単語です。
$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] => )
ただし、すべての配列から最初の単語を取得する方法をさまよっていました。たとえば、次の例のように最初の単語を取得する関数を作成するにはどうすればよいですか。
Microsoft 2 it's 3 9 The 4
ありがとう