【发布时间】:2012-12-10 18:41:34
【问题描述】:
我需要做这个棘手的事情:以随机方式选择 10 个项目,一个用于真/假标准的项目,其余 9 个要回显的项目:
$unique_items=array('bike', 'doll', 'carpet', 'postcard');
do {
$items=ORM::factory('Shop')
->order_by(DB::expr('Rand()'))//this way I take 10 random rows from the table
->limit(10)
->find_all();
}while (in_array(first_item_from_ten_rows->name, $unique_items));
foreach ($items as $item){
echo $item->name;//display 2nd, 3rd, ..., 10th items, without the first one
}
我这里使用的php框架是Kohana3.3
【问题讨论】:
-
这样使用第一行的原因是什么?
-
第一行是基本项。
标签: php foreach while-loop kohana kohana-3