开发者

How to capture textarea text WITH linebreaks and send to php?

I'm trying to experiment with taking text from a textarea in a flex project and open it up in a php page. But the php isn't line breaking where it should be...

an Example of the text i'd like to bring over to php would be:

You: Hi there
Them: Hello
You: This is a great example
Them: I know right?

Here's my php:

<?php 

$text= $_GET['text'];

echo $text;

?>

Right now I came up with something like this in the actionscript...

var chatBox:String=chat_box.text;

navigateToURL(new URLRequest("savelog.php?text="+chatBox), '_blank');

I also tried something like:

var chatBox:String=chat_box.text.valueOf().replace("\n","<br/>");

and

var chatBox:String=chat_box.text.toString().valueOf().replace("\n","<br/>");

But apparently the 开发者_如何转开发\n isn't translating over no matter how I get the chatBox var so its not even making a <br/>

But, even if i did get that to work it wouldnt be ideal. Because eventually in the end I want to be able to just incorporate the pastebin API to paste this GET data and post it on there. And I don't think it would look too pretty with having <br/> after every line...

So my questions is, is it possible to bring this text over to php and recognize the line breaks in a way that would work well with what im eventually trying to accomplish?

edit: I'm a little confused because var chatBox:String=chat_box.text.toString() actually returns the text with \n at every line break and i can see the \n on a trace statement...but when im looking in the URL text there is no \n anywhere...any ideas? because if the \n would appear the ln2br() solution might work


Take a look at ln2br() its a built in function in PHP. It also handle more than jsut the \n might be usefull in your case and i dont see that your using it yet! Try it out and let me know! You also might want to check out any encoding issues.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜