[英]Adding <li> to nl2br
<p><?php echo nl2br($course->getSubjects())?></p>
是否可以将<li>
添加到每个新行?
You can imlement it with str_replace
like the following example:您可以使用
str_replace
实现它,如下例所示:
$aaa = 'ghjh sdf \n dfg dfg \n jhdsfjk';
$list= str_replace('\n','</li><li>',$aa);
print_r('<li>'.$list);
If $course->getSubjects()
contains value then You can change your code to:如果
$course->getSubjects()
包含值,则您可以将代码更改为:
$list= str_replace('\n','</li><li>',$course->getSubjects());
print_r('<li>'.$list);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.