doushuangai9733 2013-11-11 22:09
浏览 348
已采纳

在构建字符串php时添加换行符

i have been looking all over and i cant find the answer. i am sure this is easy

i am sending an email, and in the body are names of clients

the code looks for clients that fit the search conditions and as each one is found it goes into a loop

while($row = mysql_fetch_array($result)) {
 $clients = $clients . $first_name . ???
}

the result should be

Client1
Client2
Client3

but what i keep getting is:

Client1Client2Client3

I have tried

     $clients = $clients . $first_name . lf;
     $clients = $clients . $first_name . cr;
     $clients = $clients . $first_name . '
';

but always the same result

TIA

  • 写回答

3条回答 默认 最新

  • dousaoxiancy199896 2013-11-11 22:12
    关注

    If your output will be the command line, file, etc. Use PHP_EOL. If it will be a web browser use <br>:

    while($row = mysql_fetch_array($result)) {
        $clients = $clients . $first_name . PHP_EOL;
    }
    
    while($row = mysql_fetch_array($result)) {
        $clients = $clients . $first_name . "<br/>";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教