使用PHP中的换行符爆炸数据库内容不会创建数组
问题描述:
I've stored some values in my database which have linebreaks.
Wanting to transform those contents into an array, I did it like this:
$arr = explode($rs[data],"
");
Unfortunately this doesn't work. Any ideas as to what's wrong?
我在数据库中存储了一些包含换行符的值。 p>
想要将这些内容转换为数组,我这样做: p>
$ arr = explode($ rs [data],“
”);
代码> pre>
不幸的是,这不起作用。 关于什么是错的任何想法? p>
div>
答
The parameters of your explode()
call are inverted :
- The first parameter should be the delimiter -- which will be used to explode the string
- And the second parameter should be the string -- which will be exploded.
So, you should use :
$arr = explode("
", $rs[data]);
答
$arr = explode("
",$rs[data]);
You are passing parameters wrongly try above