I've stored some values in my database which h开发者_如何转开发ave linebreaks.
Wanting to transform those contents into an array, I did it like this:
$arr = explode($rs[data],"\n");
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("\n", $rs[data]);
$arr = explode("\n",$rs[data]);
You are passing parameters wrongly try above
精彩评论