replace line feed
A php echo text with no HTML markup.
开发者_开发知识库1. one
2. two
3. three
4. four
5. five
How do I make it remove the linefeed?
1. one<br>2. two<br>3. three<br>4. four<br>5. five
I tried nl2br, string replacement still doesn't replace properly.
preg_replace it:
$some_text = ' 1. one 2. two 3. three 4. four 5. five '; echo preg_replace('~\d+\.~', '', $some_text);
nl2br is supposed to work for this.
try to mix HTML and PHP
<?php $list=array('one','two','three','four','five'); ?>
<ul >
<?php foreach ($list as $k=>$v) { ?>
<li style="display: inline;"><?php printf("%d.%s ",$k+1,$v);?></li>
<?php } ?>
</ul>
精彩评论