【发布时间】:2010-12-01 19:04:03
【问题描述】:
我的数据库中有一个带有换行符的字符串。我想将该字符串转换为一个数组,并且对于每一行,在数组中跳转一个索引位置。
如果字符串是:
My text1
My text2
My text3
我想要的结果是这样的:
Array
(
[0] => My text1
[1] => My text2
[2] => My text3
)
【问题讨论】:
-
你应该首先规范化换行符,可能。
s($yourString)->normalizeLineEndings()方法可用于 github.com/delight-im/PHP-Str(MIT 许可下的库),它有许多其他有用的字符串助手。你可能想看看源代码。
标签: php string line-breaks