dongli8862 2012-09-13 20:01
浏览 15
已采纳

列表项继续在PHP中的下一行

I am using a form to submit a list of items that I want to save to a config text file, but these list items should all be on the same line of the text file. Every time PHP breaks apart and puts the list items into the file, however, it automatically adds a new line before the </li> tag. Why? How do I prevent this.

CODE:

$pro = explode("
",$_POST["pro"]);
$proo = "<ul>";

for($index=0; $index<count($pro);$index++)
{
    $proo .= "<li>";
    $proo .= $pro[$index];
    $proo .= "</li>";
}

$proo .= "</ul>";

$proo = str_replace("
","",$proo);

Edit 1

If I echo $proo into the webpage, it looks like this:

<ul><li>List Item 1
</li><li>List Item 2
</li><li>List Item 3
</li><li>List Item 4
</li><li>List Item 5</li></ul>

Why are there line breaks before each </li>?

Somewhere in there, it's adding new lines...

Thanks!

David

  • 写回答

3条回答 默认 最新

  • dongping8572 2012-09-13 20:15
    关注

    I just had to add the following line:

    $proo = str_replace("","",$proo);
    

    For whatever reason, it was adding a return character. I don't know why still, but thanks for all your help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向