markhfla Posted April 25, 2008 Share Posted April 25, 2008 I'm trying to send text from a mysql database to a flash file through a string variable. But, the string shows up in my code with line breaks from when it was entered into the database from a form. In order for the flash file to read the string, it must all be on one line in the code. How can I remove these line breaks using PHP? I don't really want to remove them from the actual database text. Here's what I'm getting: description_text.swf?description=This is the way it's showing up with the <br> tag and on separate line. This doesn't work. Here's what I want: description_text.swf?description=This is the way I want it to show up with the<br>tag and all on one line. This does work! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 25, 2008 Share Posted April 25, 2008 str_replace("\n", "", $row['text']); Fill in the correct row. =P Quote Link to comment Share on other sites More sharing options...
markhfla Posted April 25, 2008 Author Share Posted April 25, 2008 WOW! That's the fastest response I've ever gotten. Thanks. Unfortuantely, I've tried that and it doesn't work. If this helps, here's some of the code: $desc = str_replace("'","'",$myrow["full_description"]); $desc = str_replace('"',""",$desc); $desc=str_replace("<p>","<br><br>",$desc); $desc=str_replace("\n","",$desc); Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 25, 2008 Share Posted April 25, 2008 $breaks = array("\r\n", "\n", "\r"); $newtext = str_replace($breaks, "", $text); Try that. >_> Quote Link to comment Share on other sites More sharing options...
Fadion Posted April 25, 2008 Share Posted April 25, 2008 $desc=str_replace("<p>","<br><br>",$desc); Shouldnt also be a: $desc = str_replace('</p>', '', $desc); or u usually dont close tags Quote Link to comment Share on other sites More sharing options...
markhfla Posted April 25, 2008 Author Share Posted April 25, 2008 DarkWater, A thousand blessings on your household! That worked. WHEW! GuiltyGear, I built the admin for this site years ago. So, my client just enters an open p tag. One of these days I'm going to have to get around to adding an html editor. Although, with the current problem I just had, maybe that's not such a good idea! :-P Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 25, 2008 Share Posted April 25, 2008 Any time, dude. =) Glad I could help. I hate how sometimes it's \r or \n or \r\n. D: Depends on the OS and stuff. So yeah, glad I could get that sorted out for you. Happy coding. =P Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.