PHP字符串连接

PHP字符串连接

我需要知道是否可以连接字符串,如下所示?如果没有,那么这样做的替代方案是什么?

while ($personCount < 10) {$result+= $personCount . "person ";}echo $result;

它应该像1 person 2 person 3人等......

你不能使用+登录连接,那么替代方案是什么?


UYOU
浏览 377回答 3
3回答

POPMUISE

只是.用于连接。你错过了$personCount增量!while&nbsp;($personCount&nbsp;<&nbsp;10)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;$result&nbsp;.=&nbsp;$personCount&nbsp;.&nbsp;'&nbsp;people'; &nbsp;&nbsp;&nbsp;&nbsp;$personCount++;}echo&nbsp;$result;

幕布斯6054654

一步(恕我直言)更好$result&nbsp;.=&nbsp;$personCount&nbsp;.&nbsp;'&nbsp;people';
打开App,查看更多内容
随时随地看视频慕课网APP