Php 将字符串值放入按enters分隔的数组中
我有一根这样的线:Php 将字符串值放入按enters分隔的数组中,php,arrays,Php,Arrays,我有一根这样的线: $str = " test1 test2 test3 test4 test5"; 我想把它变成: array('test1','test2','test3' ect ect) 我该怎么做 更具体地说,使用explode函数,使用行尾作为分隔符,然后将其包装在array_filter函数中,以从奇数行条目中删除任何杂散条目 $arr = array_filter(explode("\n", $str)); 干得好:
$str = "
test1
test2
test3
test4
test5";
我想把它变成:
array('test1','test2','test3' ect ect)
我该怎么做 更具体地说,使用explode函数,使用行尾作为分隔符,然后将其包装在array_filter函数中,以从奇数行条目中删除任何杂散条目
$arr = array_filter(explode("\n", $str));
干得好: