php循环遍历文本区域中的每一行字符串


php loop through each string line in textarea

我使用这个脚本来获取数组中文本区域的每一行:

//trim off excess whitespace off the whole
$text = trim(get_field('backlinks'));
//explode all separate lines into an array
$textAr = explode("'n", $text);
//trim all lines contained in the array.
$textAr = array_filter($textAr, 'trim');
//loop through the lines
var_dump($textAr);
foreach ($textAr as $line) {
    echo $line; 
}

我从var_dump输出的是:

 array(3) { [0]=> string(29) "
 http://www.nasa.gov/
 " [1]=> string(25) "http://www.cnn.com/
 " [2]=> string(27) "http://www.twitter.com/
 " }

我从echo $line;输出的html是:

http://www.nasa.gov/<br>
http://www.cnn.com/<br>
http://www.twitter.com/

我的脚本处理错误。我需要echo $line;的输出为:

http://www.nasa.gov/http://www.cnn.com/http://www.twitter.com/

我的var_dump的输出是:

array(3) { [0]=> string(29) "http://www.nasa.gov/" [1]=> string(25) "http://www.cnn.com/" [2]=> string(27) "http://www.twitter.com/" }

我不希望我的输出/回波出现断线。我做错了什么?

提前感谢

//trim off excess whitespace off the whole
$text = trim(get_field('backlinks'));
//explode all separate lines into an array
$textAr = explode("'n", $text);
//trim all lines contained in the array.
$textAr = array_filter($textAr, 'trim');
//loop through the lines
var_dump($textAr);
foreach($textAr as $line) {
    echo str_replace("'n","",str_replace("'r","",$line)); 
}

尝试使用内爆。

echo内爆(",",$textAr);

对不起,我以为这是PHP代码,这是我的文本区域的一个设置,它的广告<br>每行之后。