pixeltrace Posted February 24, 2007 Share Posted February 24, 2007 guys, i need help i have a form wherein in i have a textarea name="requirements" example of the text i am typing there is item1 item2 item3 item4 and this text will then be submitted and saved to my database my problem now is when i view it in my view page the format of the text i typed is item1item2item3item4 how do i fix this wherein when i view it in my view page the output will be * item1 * item2 * item3 * item4 need help on this please! thanks in advance! Link to comment https://forums.phpfreaks.com/topic/39883-solved-need-help-on-bulleted-output-from-textarea/ Share on other sites More sharing options...
JBS103 Posted February 24, 2007 Share Posted February 24, 2007 Do you have any sort of punctuation or symbols in between the items or does it simply look like: applesorangesbananaspearsfruits? If you have symbols, or you can add them, you can use explode() and then loop through the array to display them in a list. Link to comment https://forums.phpfreaks.com/topic/39883-solved-need-help-on-bulleted-output-from-textarea/#findComment-192755 Share on other sites More sharing options...
emehrkay Posted February 24, 2007 Share Posted February 24, 2007 each item should have a new line after it \n you could do $list = expolode("\n", $data); //i think the double quote will mater here $count = count($list); $disp = "<ul>\n"; for($i = 0; $i < $count; $i++){ $disp .= "<li>". $data[$i] ."</li>\n"; } echo $disp .= "</ul>\n"; Link to comment https://forums.phpfreaks.com/topic/39883-solved-need-help-on-bulleted-output-from-textarea/#findComment-192758 Share on other sites More sharing options...
pixeltrace Posted February 24, 2007 Author Share Posted February 24, 2007 thanks i will try this one Link to comment https://forums.phpfreaks.com/topic/39883-solved-need-help-on-bulleted-output-from-textarea/#findComment-192764 Share on other sites More sharing options...
kenrbnsn Posted February 24, 2007 Share Posted February 24, 2007 Another way to do this would be: <?php $list = explode("\n",$data); echo "<ul>\n<li>" . implode("</li>\n<li>",$list) . "</li>\n</ul>\n"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/39883-solved-need-help-on-bulleted-output-from-textarea/#findComment-192792 Share on other sites More sharing options...
superuser2 Posted February 24, 2007 Share Posted February 24, 2007 Another way to do this would be: <?php $list = explode("\n",$data); echo "<ul>\n<li>" . implode("</li>\n<li>",$list) . "</li>\n</ul>\n"; ?> Ken That would be the simplest way. Link to comment https://forums.phpfreaks.com/topic/39883-solved-need-help-on-bulleted-output-from-textarea/#findComment-192931 Share on other sites More sharing options...
pixeltrace Posted February 24, 2007 Author Share Posted February 24, 2007 thanks to the help its working now. Link to comment https://forums.phpfreaks.com/topic/39883-solved-need-help-on-bulleted-output-from-textarea/#findComment-192936 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.