【发布时间】:2016-01-13 10:39:45
【问题描述】:
我有这段代码
$limit = 100;
$offset = 0;
while (array() === ($contactIdList = $this->getData($limit, $offset))) {
$count = count($contactIdList);
//using $count and $contactIdList for doing some logging stuff
$offset += $limit;
}
$this->getData($offset) //从我们设置$limit,$offset的查询返回结果数组,所以当所有结果都被获取时,它返回空数组并且这个while条件结束。
我的问题是我在 while 条件中将数组结果分配给 $contactIdList 以在 while 条件内保存一行 $contactIdList = $this->getData($limit, $offset)。这是正确的方法吗?
【问题讨论】:
标签: php arrays while-loop conditional