开发者

Exploding database content with linebreaks in PHP doesn't create array

开发者 https://www.devze.com 2023-02-21 07:30 出处:网络
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:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消