How to keep new lines when outputting posts retrieved from Facebook using the Graph API?
Say fo开发者_StackOverflowr example the original post on facebook is as follows:
Stack Overflow
Stack Overflow
Stack Overflow
The array returned from the graph api will have the following data:
[message] => Stack Overflow
Stack Overflow
Stack Overflow
So there are newlines within the returned array data but when I am echoing the data out I simply get Stack Overflow Stack Overflow Stack Overflow
Is there a straightforward way to keep the original structure of the post?
All I am doing to echo it is:
echo "<div class=\"post\">".$user_feed['data'][$i]['message']."</div>\n";
Thanks,
echo "<div class=\"post\">".nl2br($user_feed['data'][$i]['message'])."</div>\n";
have you tried wrapping it in a
<pre>
tag (i.e. preformated). Or you could replace new lines with line-breaks
<br />
精彩评论