开发者

Problem printing PHP output on multiple lines

I am newbie to PHP I have written the followin开发者_JAVA技巧g program:

$address=array('abc@gmail.com','abc@hotmail.com','def@yahoo.com');

foreach($address as $value)
{
     echo "processing $value\n";
}

If you see I have \n in the echo statement but I am not getting the output on new line.

How can I get each output on a new line?


If you are outputting this as HTML then you must of course use a HTML break <br />.


If you're working in a browser, you need to break lines with

<br>


You need to print an HTML line break instead:

<br/>

Since you are printing to a browser


\n will line break properly when you view the source, but not in the HTML display. As mentioned, you need to use the <br/> node for HTML


You may want to wrap your output in a <pre> tag as your browser is expecting HTML and is just collapsing the whitespace. The pre tag will reflect the whitespace (\t \n etc);

Alternately you can use a break tag, or wrap the data in a block display element. (eg: <p> or <div>)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜