如何检测带有空格的换行符


How to detect a newline with space

我的字符串是"妈妈爸爸"(也在表 DB 中保存相同的属性)。

查询并打印到表后,我想用空格分隔换行符。输出应该是妈妈+换行符+爸爸,但它打印"妈妈爸爸"而不换行。

像这样使用 PHP explode() 函数:

<?php
    $input = "mom dad";
    $inputArray = explode(" ", $input);
    //now inputArray is like this ["mom", "dad", ...]
    echo $inputArray[0]."<br>".$inputArray[1];
?>

希望对你有帮助谢谢