Maison >développement back-end >tutoriel php >PHP入门1 for循环
<code><span><span><?php </span><span>$x</span> = <span>$_GET</span>[<span>'name'</span>]; <span>echo</span><span>$x</span>; <span>for</span>(<span>$i</span> =<span>$x</span>;<span>$i</span>100</span>;<span>$i</span>++) { <span>echo</span><span>$i</span>,<span>"<br>"</span>; } <span>$TmpArray</span> = [<span>"A"</span>,<span>"B"</span>,<span>"C"</span>,<span>"D"</span>]; <span>foreach</span>(<span>$TmpArray</span><span>as</span><span>$i</span>) { <span>echo</span><span>$i</span> . <span>"<br>"</span>; } <span>?></span></span></code>
foreach循环迭代数组,跟常见的用法不一样,C++中
foreach (零时变量 in array)
php:
foreach (array as 零时变量)
以上就介绍了 PHP入门1 for循环,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。