在PHP中的'echo'中添加for循环

kha*_*itz -3 php loops

是否有可能在PHP echofor loop它里面?像这样的东西:

echo "This are the list" . for($i=0; $i<=$count; $i++) { echo $variable1 . $variable2} . "End";
Run Code Online (Sandbox Code Playgroud)

我的代码是这样的.

但我仍然遇到错误.

Han*_*nky 5

循环不要进入echo语句.将它们分开

echo "This are the list";
for($i=0; $i<=$count; $i++)
{
 echo $variable1 . $variable2;
} 
echo "End";
Run Code Online (Sandbox Code Playgroud)

将通过以下方式生成更可读的输出版本:

echo "This is the list: <br>";
for($i=0; $i<=$count; $i++)
{
 echo $variable1. " ". $variable2."<br>";
} 
echo "End";
Run Code Online (Sandbox Code Playgroud)