本文整理匯總了PHP中Iterator::getArrayCopy方法的典型用法代碼示例。如果您正苦於以下問題:PHP Iterator::getArrayCopy方法的具體用法?PHP Iterator::getArrayCopy怎麽用?PHP Iterator::getArrayCopy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Iterator
的用法示例。
在下文中一共展示了Iterator::getArrayCopy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: multiSort
/**
* @return void
*/
private function multiSort()
{
if (!$this->sortPended || empty($this->sortingCommands)) {
return;
}
// set pended to false before toArray is performed to avoid infinite loop.
$this->sortPended = false;
$itArray = $this->it instanceof \ArrayIterator ? $this->it->getArrayCopy() : $this->toArray();
if (count($this->sortingCommands) === 1) {
$command = $this->sortingCommands[0];
if (!is_null($command->getComparator())) {
usort($itArray, function ($first, $second) use($command) {
return -$command->getSortOrder() * $command->getComparator()->compare($first, $second);
});
} else {
if ($command->getSortOrder() === SortOrder::ASC) {
sort($itArray);
} else {
rsort($itArray);
}
}
} else {
$itArray = $this->quickSort($itArray, $this->sortingCommands);
}
$this->it = new \ArrayIterator($itArray);
}
示例2: getTraversable
/**
* Get the item that's being traversed.
*
* @return \Traversable|array
*/
public function getTraversable()
{
if ($this->traversable instanceof ArrayIterator) {
$array = $this->traversable->getArrayCopy();
for ($i = 0; $i < $this->i; $i++) {
next($array);
}
return $array;
}
return $this->traversable;
}
示例3: getRaw
/**
* Returns original data.
*
* @return array|\Traversable
*
* @throws DataException
*/
public function getRaw()
{
switch ($this->type) {
case self::TYPE_ARRAY:
return $this->data->getArrayCopy();
case self::TYPE_ITERATOR:
return $this->data;
case self::TYPE_AGGREGATE:
return $this->data->getInnerIterator();
}
throw DataException::invalidCollectionData($this->data);
}