php循环遍历textarea中的每个字符串行

php循环遍历textarea中的每个字符串行,php,foreach,explode,Php,Foreach,Explode,我使用此脚本从数组中的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($t

我使用此脚本从数组中的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输出是:

echo$行的html输出;是:

我的var_dump的输出为:

我不希望输出/回音中出现换行。我做错了什么

提前感谢

尝试使用impload

回波内爆,$textAr

尝试使用内装


回波内爆,$textAr

对不起,我想这是PHP代码,这是我文本区域的一个设置,它的广告是

在每一行之后。

对不起,我认为这是PHP代码,它是我文本区域的一个设置,在那里它的广告
//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)); 
}


每行后面。

在$text变量中有什么?这里似乎有一些br标记,您可能没有考虑到换行符可以由多个单独的\n表示,但也可以有一个额外的\r标记。或者在某些[旧]系统上只有一个\r。在$text变量中有什么?这里似乎有一些br标记,您可能没有考虑到换行符可以由多个单独的\n表示,但也可以有一个额外的\r标记。或仅在某些[旧]系统上\r。
//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)); 
}
http://www.nasa.gov/http://www.cnn.com/http://www.twitter.com/
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)); 
}