Jump to content

[SOLVED] Remove New Line


The Little Guy

Recommended Posts

in my following code, I break a text field from my db into an array (works).

DB field answers may look like this:

dog
cat
pig

 

if I were to take the following code and break it up, into an array like in my following code, I get a line break after $q I need to remove it, but the following code won't, so my javascript doesn't work. Any suggestions?

 

$qs = explode("\n",$row['answers']);
foreach($qs as $q){
$q = str_replace("\n",'',$q);
echo '<span class="feed"><input type="radio" name="question" onclick="submitPoll(\''.$q.'\')" id="poll_'.$q.'" /> <label for="poll_'.$q.'">'.$q.'</label><br /></span>';
}

Link to comment
https://forums.phpfreaks.com/topic/111511-solved-remove-new-line/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.