[PHP]半角スペースで文章を区切る方法
explodeを使用する
<?php
// Input sentence
$sentence = "This is a sample sentence to split.";
// Split the sentence into an array of words using space as the delimiter
$words = explode(" ", $sentence);
// Loop through the array of words and print each word
foreach ($words as $word) {
echo $word . "<br>";
}
?>