使用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?

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