Reputation: 12067
I have options stored in the database in the following format -
option1:Option 1;option2:Option 2;option3:Option 3;option4:Option 4
Users are able to edit these options, so when they are in the <textarea>
I'd like for them to be displayed on seperate lines.
option1:Option 1
option2:Option 2
option3:Option 3
option4:Option 4
I'm trying to do this by replacing the ';'
character that seperates the options with a new line (str_replace(';', PHP_EOL, $poll['poll_options'])
- have also tried "\r\n"
)
Even though this appears to be working (echo '<pre>'; print_r($poll['poll_options']); echo '</pre>';
shows the options correcty on a new line), when I place the text in a <textarea>
the options are only seperated be a space.
Edit - I've changed the code I used (now reflected in this post) to that suggested by @John Conde, and it now works in FF.
Any tips on how to resolve? Thanks.
Upvotes: 0
Views: 1150
Reputation: 219884
Try:
$new_text = str_replace(';', PHP_EOL, $poll['poll_options']);
str_replace()
is easier to work with then regular expressions.
Upvotes: 5