当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayIterator::count方法代码示例

本文整理汇总了PHP中ArrayIterator::count方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayIterator::count方法的具体用法?PHP ArrayIterator::count怎么用?PHP ArrayIterator::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayIterator的用法示例。


在下文中一共展示了ArrayIterator::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search

 /**
  *
  * @param <type> $table
  * @param ArrayIterator $params
  * @return ArrayObject
  */
 public function search($table, ArrayIterator $params)
 {
     $this->searchParams = $params;
     $this->join();
     if ($table == "analysis") {
         $this->statements->remove("type_event");
     }
     $statement = "SELECT this_.* " . $this->selectAttributes() . " FROM {$table} this_ ";
     $statement .= $this->join();
     $i = 0;
     $this->searchParams->rewind();
     if ($this->searchParams->count() > 0 && !$this->searchParams->offsetExists('true')) {
         $statement .= " WHERE ";
     }
     while ($this->searchParams->valid()) {
         if ($this->statements->containsKey($this->searchParams->key())) {
             if ($i++ > 0) {
                 $statement .= " AND ";
             }
             $clause = $this->statements->get($this->searchParams->key());
             $statement .= str_replace(":" . $this->searchParams->key(), "'" . $this->searchParams->current() . "'", $clause['where']);
         }
         $this->searchParams->next();
     }
     return $this->getObject($statement . " ORDER BY this_.date DESC, this_.id DESC");
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:32,代码来源:SearchEngine.php

示例2: getRows

 /**
  * @param int $groupPosition
  * @return array
  */
 public function getRows($groupPosition)
 {
     $rows = [];
     $columns = $this->getAllAggregationColumns();
     if ($groupPosition == Group::GROUP_VERTICAL) {
         foreach ($this->arrayIterator as $current) {
             $cols = [$this->getRealEntityName((int) $current['key'])];
             foreach ($columns as $aggrIndex => $aggrFieldNames) {
                 $aggregationData = $this->extractDataFromAggregation($aggrIndex, $aggrFieldNames, $current);
                 foreach ($aggregationData as $value) {
                     array_push($cols, $value);
                 }
             }
             $rows[] = $cols;
         }
     } else {
         $assocAggregationList = ArrayHelper::index($this->aggregationList, 'index');
         foreach ($columns as $aggrIndex => $aggrFieldNames) {
             $rows[] = ['colspan' => $this->arrayIterator->count() + 1, 'value' => $assocAggregationList[$aggrIndex]['title']];
             foreach ($aggrFieldNames as $fieldName) {
                 $cols = [$fieldName];
                 foreach ($this->arrayIterator as $current) {
                     $cols[] = $this->findValue($current[$aggrIndex], $fieldName);
                 }
                 $rows[] = $cols;
             }
         }
     }
     $this->arrayIterator->rewind();
     return $rows;
 }
开发者ID:anmoroz,项目名称:yii2-analytics,代码行数:35,代码来源:ViewHelperComponent.php

示例3: solve

 /**
  * {@inheritdoc}
  */
 public function solve(\Iterator $operations, \Iterator $items)
 {
     // search for all UnaryOperations
     $tempResult = $items;
     $unaryChain = new \ArrayIterator();
     foreach ($operations as $operation) {
         // collect all unary operators
         if ($operation instanceof IntermediateOperationInterface) {
             $unaryChain->append($operation);
         } else {
             // execute all the collected unary operations
             if ($unaryChain->count() > 0) {
                 $tempResult = $this->solveIntermediateOperationChain($unaryChain, $tempResult);
                 $unaryChain = new \ArrayIterator();
             }
             // execute full set operations (like sort)
             if ($operation instanceof FullSetOperationInterface) {
                 $tempResult = $operation->apply($tempResult);
             }
         }
     }
     // resolve the rest of the unary operation
     if ($unaryChain->count() > 0) {
         $tempResult = $this->solveIntermediateOperationChain($unaryChain, $tempResult);
     }
     return $tempResult;
 }
开发者ID:peekandpoke,项目名称:psi,代码行数:30,代码来源:DefaultOperationChainSolver.php

示例4: update

 /**
  * Update = $sql = "UPDATE tabla SET campo1 = ?, campo2 = ?, campo3 = ?
  * WHERE idcampo = ?"
  * $stm->bindValue(4, idValor);  
  */
 public function update($table, $data, $where, $id)
 {
     $result = null;
     $iterator = new ArrayIterator($data);
     $sql = "UPDATE {$table} SET ";
     while ($iterator->valid()) {
         $sql .= $iterator->key() . " = ?, ";
         $iterator->next();
     }
     //Se elimina los dos ultimos caracteres (la coma y el espacio)
     $sql = substr($sql, 0, -2);
     $sql .= " WHERE {$where} = ?";
     $stm = $this->_getDbh()->prepare($sql);
     $i = 1;
     foreach ($iterator as $param) {
         $stm->bindValue($i, $param);
         $i++;
     }
     /**
      * Se asigna el bindValue para el parametro $id, como no esta contemplado en los ciclos del $data,
      * se asigna en la posicion ($iterator->count()+1) y se le asigna el tipo de dato: PDO::PARAM_INT 
      */
     $stm->bindValue($iterator->count() + 1, $id, PDO::PARAM_INT);
     $result = $stm->execute();
     return $result;
 }
开发者ID:paarma,项目名称:BibliotecaFupWeb,代码行数:31,代码来源:DbCrud.php

示例5: __construct

 /**
  * Consumes data, turns the data into an array and stores it.
  * This data can then be iterated.
  *
  * If count is provided, a custom count is set (for pagination
  * purposes). Otherwise, the length of the data property is
  * taken as the count value.
  *
  * @throws ResultException
  *
  * @param mixed $aData
  * @param int   $iCount
  */
 public function __construct($aData, $iCount = null)
 {
     if ($iCount && !is_numeric($iCount)) {
         throw new ResultException('Count must be numeric!');
     }
     if (!is_array($aData)) {
         $aData = array($aData);
     }
     $this->oDataIterator = new \ArrayIterator($aData);
     if ($aData === false) {
         $this->iCount = 0;
     } else {
         $this->iCount = $iCount ? (int) $iCount : $this->oDataIterator->count();
     }
     $this->setSearchParams(array());
 }
开发者ID:kp-favorite,项目名称:bitfalls_utils,代码行数:29,代码来源:Result.php

示例6: __construct

 /**
  * Default constructor to load the iterator. Override the parent
  * LimitIterator as we don't want to return 
  *
  * @access	public
  * @param	ArrayIterator	$it
  */
 public function __construct(ArrayIterator $it, $page = 1, $limit = 10)
 {
     $this->_it = $it;
     $this->_count = $it->count();
     $this->setCurrentPage($page);
     $this->setItemsPerPage($limit);
 }
开发者ID:pixlr,项目名称:ZCE-PHP-Cert,代码行数:14,代码来源:limit-iterator.php

示例7: average

 public function average(ArrayIterator $values)
 {
     $sum = 0;
     while ($values->valid()) {
         $sum += $values->current();
         $values->next();
     }
     $values->rewind();
     return round($sum / $values->count(), 2);
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:10,代码来源:Statistic.php

示例8: extractResponse

 /**
  * Extract response from Sender - depends on sender
  *
  * @param Response $response
  *
  * @return array('status_code', 'status_description', 'batch_id')
  * @throws BulkSmsException
  */
 public function extractResponse(Response $response)
 {
     $expected = array('status_code', 'status_description', 'batch_id');
     $parts = explode('|', $response->body);
     $it = new \ArrayIterator($parts);
     if (count($expected) != $it->count()) {
         throw new BulkSmsException("Count of BulkSMS response does not match expectations!. Return: " . $response->body);
     }
     $toreturn = [];
     foreach ($expected as $item) {
         $toreturn[$item] = $it->current();
         $it->next();
     }
     return $toreturn;
 }
开发者ID:roarkmccolgan,项目名称:php-bulk-sms,代码行数:23,代码来源:Single.php

示例9: container

 /**
  *
  * @param Collection|Container $model
  * @param int $arg
  * @return string
  */
 public function container(Container $model, $arg)
 {
     $string = '';
     $cols = isset($model->config['columns']) && $model->config['columns'] > 0 ? $model->config['columns'] : 1;
     $width = floor(12 / $cols);
     $break = $arg;
     $it = new ArrayIterator($model->getModels());
     $item_left = $it->count();
     while ($it->valid()) {
         $column = '';
         $break += ceil($item_left / $cols);
         while ($it->valid() && $arg < $break) {
             $column .= '<div class="row"><div class="col-md-12 list-item">' . $this->visit($it->current(), $arg) . '</div></div>';
             $it->next();
             $item_left--;
             $arg++;
         }
         $cols--;
         $string .= '<div class="col-md-' . $width . ' list-column">' . $column . '</div>';
     }
     return '<div class="row list">' . $string . '</div>';
 }
开发者ID:Stephan123,项目名称:markdown_blog,代码行数:28,代码来源:View.php

示例10: extractResponse

 /**
  * Extract response from Sender - depends on sender
  *
  * @param Response $response
  *
  * @return array('msisdn', 'status_code')
  * @throws BulkSmsException
  */
 public function extractResponse(Response $response)
 {
     // dump the first 2 lines indicated by the string "0|Returns to follow\n\n"
     $cleaned = substr($response->body, strlen("0|Returns to follow\n\n"), strlen($response->body));
     $statusitems = explode("\n", $cleaned);
     $siit = new \ArrayIterator(array_filter($statusitems));
     $toreturn = [];
     foreach ($siit as $item) {
         $expected = array('msisdn', 'status_code');
         $parts = explode('|', $item);
         $it = new \ArrayIterator($parts);
         if (count($expected) != $it->count()) {
             throw new BulkSmsException("Count of BulkSMS response does not match expectations!. Return: " . $response->body);
         }
         $status = [];
         foreach ($expected as $statusitem) {
             $status[$statusitem] = $it->current();
             $it->next();
         }
         $toreturn[] = $status;
     }
     return $toreturn;
 }
开发者ID:roarkmccolgan,项目名称:php-bulk-sms,代码行数:31,代码来源:Status.php

示例11: filter

 /**
  * @inheritDoc
  */
 public function filter(RoundGearsInterface $previousRoundGears)
 {
     $advance = $previousRoundGears->getRound()->getSetup()->getAdvance();
     // -1 = all
     $leaderBoard = $previousRoundGears->getLeaderBoard();
     $result = array();
     $groupNumbers = $leaderBoard->getGroupNumbers();
     foreach ($groupNumbers as $groupNumber) {
         $result[$groupNumber] = array();
     }
     $groupNumberStepped = function ($step) use($groupNumbers) {
         $it = new \ArrayIterator($groupNumbers);
         $it->seek($step % $it->count());
         return $it->current();
     };
     $players = $leaderBoard->getEntries($advance);
     $step = 0;
     foreach ($groupNumbers as $groupNumber) {
         $groupAdvance = -1 == $advance ? count($players[$groupNumber]) : $advance;
         for ($i = 0; $i < $groupAdvance; ++$i) {
             $result[$groupNumberStepped($step + $i)][] = $players[$groupNumber][$i]->getPlayer();
         }
         $step += $this->getSteps();
     }
     //        $step = 0;
     //        for ($i = 0; $i < $advance; ++$i) {
     //            foreach ($groupNumbers as $groupNumber) {
     //                $result[$groupNumberStepped($step+1)][] = $players[$groupNumber][$i];
     //            }
     //
     //            $step += $this->getSteps();
     //        }
     //        dump($players, $result);
     // TODO implement input step : filter
     //        throw new \Exception('TODO');
     return $result;
 }
开发者ID:nehlsen,项目名称:fdadsb,代码行数:40,代码来源:InputStep.php

示例12: getDirectoryItemList

 protected function getDirectoryItemList($path, $start, $numberOfItems, array $filterMethods, $itemHandlerMethod, $itemRows = array(), $recursive = FALSE)
 {
     $realPath = rtrim($this->absoluteBasePath . trim($path, '/'), '/') . '/';
     if (!is_dir($realPath)) {
         throw new \InvalidArgumentException('Cannot list items in directory ' . $path . ' - does not exist or is no directory', 1314349666);
     }
     if ($start > 0) {
         $start--;
     }
     // Fetch the files and folders and sort them by name; we have to do
     // this here because the directory iterator does return them in
     // an arbitrary order
     $items = $this->getFileAndFoldernamesInPath($realPath, $recursive);
     natcasesort($items);
     $iterator = new \ArrayIterator($items);
     if ($iterator->count() == 0) {
         return array();
     }
     $iterator->seek($start);
     if ($path !== '' && $path !== '/') {
         $path = '/' . trim($path, '/') . '/';
     }
     // $c is the counter for how many items we still have to fetch (-1 is unlimited)
     $c = $numberOfItems > 0 ? $numberOfItems : -1;
     $items = array();
     while ($iterator->valid() && ($numberOfItems == 0 || $c > 0)) {
         // $iteratorItem is the file or folder name
         $iteratorItem = $iterator->current();
         // go on to the next iterator item now as we might skip this one early
         $iterator->next();
         $identifier = $path . $iteratorItem;
         if ($this->applyFilterMethodsToDirectoryItem($filterMethods, $iteratorItem, $identifier, $path) === FALSE) {
             continue;
         }
         if (isset($itemRows[$identifier])) {
             list($key, $item) = $this->{$itemHandlerMethod}($iteratorItem, $path, $itemRows[$identifier]);
         } else {
             list($key, $item) = $this->{$itemHandlerMethod}($iteratorItem, $path);
         }
         if (empty($item)) {
             continue;
         }
         $items[$key] = $item;
         // Decrement item counter to make sure we only return $numberOfItems
         // we cannot do this earlier in the method (unlike moving the iterator forward) because we only add the
         // item here
         --$c;
     }
     return $items;
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:50,代码来源:LocalDriver.php

示例13: getDirectoryItemList

 /**
  * Generic wrapper for extracting a list of items from a path.
  *
  * @param string $folderIdentifier
  * @param int $start The position to start the listing; if not set, start from the beginning
  * @param int $numberOfItems The number of items to list; if set to zero, all items are returned
  * @param array $filterMethods The filter methods used to filter the directory items
  * @param bool $includeFiles
  * @param bool $includeDirs
  * @param bool $recursive
  * @param string $sort Property name used to sort the items.
  *                     Among them may be: '' (empty, no sorting), name,
  *                     fileext, size, tstamp and rw.
  *                     If a driver does not support the given property, it
  *                     should fall back to "name".
  * @param bool $sortRev TRUE to indicate reverse sorting (last to first)
  * @return array
  * @throws \InvalidArgumentException
  */
 protected function getDirectoryItemList($folderIdentifier, $start = 0, $numberOfItems = 0, array $filterMethods, $includeFiles = true, $includeDirs = true, $recursive = false, $sort = '', $sortRev = false)
 {
     $folderIdentifier = $this->canonicalizeAndCheckFolderIdentifier($folderIdentifier);
     $realPath = $this->getAbsolutePath($folderIdentifier);
     if (!is_dir($realPath)) {
         throw new \InvalidArgumentException('Cannot list items in directory ' . $folderIdentifier . ' - does not exist or is no directory', 1314349666);
     }
     if ($start > 0) {
         $start--;
     }
     $items = $this->retrieveFileAndFoldersInPath($realPath, $recursive, $includeFiles, $includeDirs, $sort, $sortRev);
     $iterator = new \ArrayIterator($items);
     if ($iterator->count() === 0) {
         return array();
     }
     $iterator->seek($start);
     // $c is the counter for how many items we still have to fetch (-1 is unlimited)
     $c = $numberOfItems > 0 ? $numberOfItems : -1;
     $items = array();
     while ($iterator->valid() && ($numberOfItems === 0 || $c > 0)) {
         // $iteratorItem is the file or folder name
         $iteratorItem = $iterator->current();
         // go on to the next iterator item now as we might skip this one early
         $iterator->next();
         if (!$this->applyFilterMethodsToDirectoryItem($filterMethods, $iteratorItem['name'], $iteratorItem['identifier'], $this->getParentFolderIdentifierOfIdentifier($iteratorItem['identifier']))) {
             continue;
         }
         $items[$iteratorItem['identifier']] = $iteratorItem['identifier'];
         // Decrement item counter to make sure we only return $numberOfItems
         // we cannot do this earlier in the method (unlike moving the iterator forward) because we only add the
         // item here
         --$c;
     }
     return $items;
 }
开发者ID:graurus,项目名称:testgit_t37,代码行数:54,代码来源:LocalDriver.php

示例14: array

echo "===Array===\n";
$a = array('zero' => 0, 'one' => 1, 'two' => 2);
$it = new ArrayIterator($a);
var_dump($it->count());
foreach ($it as $key => $val) {
    echo "{$key}=>{$val}\n";
    var_dump($it->count());
}
var_dump($it->count());
echo "===Object===\n";
class test
{
    public $zero = 0;
    protected $pro;
    public $one = 1;
    private $pri;
    public $two = 2;
}
$o = new test();
$it = new ArrayIterator($o);
var_dump($it->count());
foreach ($it as $key => $val) {
    echo "{$key}=>{$val}\n";
    var_dump($it->count());
}
var_dump($it->count());
?>
===DONE===
<?php 
exit(0);
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:array_012.php

示例15: Concat

 /**
  * Concatenates this with given $array
  * 
  * @param Array $array
  * @return Plinq
  */
 public function Concat(array $array)
 {
     $this->rewind();
     $array = new \ArrayIterator($array);
     $array->rewind();
     $total = $array->count();
     for ($i = 0; $i < $total; $i++) {
         $value = $array->current();
         $key = $array->key();
         $array->next();
         $this[$key] = $value;
     }
     return $this;
 }
开发者ID:tmaski45,项目名称:tedmatuszewski.com,代码行数:20,代码来源:Plinq.php


注:本文中的ArrayIterator::count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。