【发布时间】:2014-01-14 11:21:00
【问题描述】:
我在循环中有这个 div
我想做的是
如果第一个<div>采用$a变量,第二个<div>希望它采用$b变量等等
所以基本上结构是
<?php
$a = '1';
$b = '2';
while(...){
//// if this div take $a variable
//// the next div will take $b variable
//// and the 3rd div take $a variable and so on
echo "<div id='$a OR $b'>This is a Div</div>";
}
?>
【问题讨论】:
-
请发布有效代码。
-
另外,
ids 应该是唯一的,所以整个任务没有意义。 -
您声明您想要
enter a number randomly,但从您的代码看来,您似乎只想使用最后未使用的值?哪个不是随机的...只是交替的值...您要的是哪个? -
刚刚编辑了问题以便更容易理解
标签: php variables loops while-loop