/** * * @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"); }
/** * @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; }
/** * {@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; }
/** * 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; }
/** * 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()); }
/** * 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); }
public function average(ArrayIterator $values) { $sum = 0; while ($values->valid()) { $sum += $values->current(); $values->next(); } $values->rewind(); return round($sum / $values->count(), 2); }
/** * 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; }
/** * * @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>'; }
/** * 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; }
/** * @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; }
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; }
/** * 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; }
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);
/** * 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; }
private function iterateCollection(\ArrayIterator $oIterator) { $arrayReturn = array(); if ($oIterator->count() <= 0) { return $arrayReturn; } while ($oIterator->valid()) { $oShape = $oIterator->current(); if ($oShape instanceof AbstractDrawingAdapter) { $arrayReturn[] = $oShape; } elseif ($oShape instanceof Chart) { $arrayReturn[] = $oShape; } elseif ($oShape instanceof Group) { $arrayGroup = $this->iterateCollection($oShape->getShapeCollection()->getIterator()); $arrayReturn = array_merge($arrayReturn, $arrayGroup); } $oIterator->next(); } return $arrayReturn; }
/** * Extracts trans message from PHP tokens. * * @param array $tokens * @param MessageCatalogue $catalog */ protected function parseTokens($tokens, MessageCatalogue $catalog) { $tokenIterator = new \ArrayIterator($tokens); for ($key = 0; $key < $tokenIterator->count(); $key++) { foreach ($this->sequences as $sequence) { $message = ''; $tokenIterator->seek($key); foreach ($sequence as $item) { $this->seekToNextReleventToken($tokenIterator); if ($this->normalizeToken($tokenIterator->current()) == $item) { $tokenIterator->next(); continue; } elseif (self::MESSAGE_TOKEN == $item) { $message = $this->getMessage($tokenIterator); break; } else { break; } } if ($message) { $catalog->set($message, $this->prefix . $message); break; } } } }
static function CreateURL($controller, $action, ArrayIterator $param = null) { $parameters = ""; if ($param != null) { $parameters = "&"; for ($var = 0; $var < $param->count(); $var++) { $param->seek($var); $field = $param->key(); $value = $param->current(); $parameters = $parameters . "{$field} = {$value}"; if ($var + 1 < $param->count()) { $parameters = $parameters . "&"; } } } $url = HOST_NAME . URL . "={$controller}&action={$action} {$parameters}"; return $url; }
/** * Generating file content based on the given data * * @throws \InvalidArgumentException */ public function setRecord() { if (func_num_args() != 1) { throw new InvalidArgumentException("Invaild number of arguments given. Expecting an array."); } $data = func_get_args(); $cc = new \ArrayIterator($data[0]); if ($cc->count() < 1) { throw new InvalidArgumentException("Invaild collection data."); } while ($cc->valid()) { $item = $cc->current(); $cc->next(); // if sender details are given as parameter than merge with default $senderDetails = isset($item['senderDetails']) ? array_merge($this->config['senderDetails'], $item['senderDetails']) : $this->config['senderDetails']; // for SKEL file type remove following fields if ($this->config['header_record']['header_file_type'] === 'SKEL') { unset($senderDetails['senderContactName']); unset($senderDetails['senderContactNumber']); unset($senderDetails['senderVehicle']); unset($senderDetails['senderPaymentMethod']); unset($senderDetails['senderPaymentValue']); } // check that mandatory fields specified [not null] try { array_count_values($senderDetails); } catch (ErrorException $e) { throw new InvalidArgumentException("Mandatory field " . array_search(null, $senderDetails, true) . " must not be NULL!"); } // Setting sender record // increment record count $this->config['footer_record']['trailer_record_count']++; $this->fileContent .= implode($this->config['delimiterChar'], $senderDetails) . "\r\n"; // generate consignment number $this->config['deliveryDetails']['consignment_number'] = implode('', $this->config['dr_consignment_number']); // increment consignment number for next package $this->getConsignmentNumber(); $this->setConsignmentNumber(); //merge with default delivery details $deliveryDetails = array_merge($this->config['deliveryDetails'], $item['deliveryDetails']); // check that mandatory fields specified [not null] try { array_count_values($deliveryDetails); } catch (ErrorException $e) { throw new InvalidArgumentException("Mandatory field " . array_search(null, $deliveryDetails, true) . " must not be NULL!"); } // increment record count $this->config['footer_record']['trailer_record_count']++; // Setting delivery record $this->fileContent .= implode($this->config['delimiterChar'], $deliveryDetails) . "\r\n"; } }
/** * Register list of files/files object into current view by type * @param string $type Register files as (e.g., js|css) * @param array|null $list List of File[] array | simple list | Include all files * @param array $options (optional) Additional options pass to file while registering files * @param callable|null $callback (optional) Apply callback on each registering file * <code> * function (string &$fileUrl, string &$fileId, boolean $excluded, boolean $included ) { * // some logic here ... * } * </code> */ public function registerFilesAs($type, $list, array $options = [], callable $callback = null) { if (!is_string($type) || empty($type)) { throw new InvalidParamException("Type must be a string and cannot empty"); } if (is_null($list)) { $list = $this->getFiles(); } $itr = new \ArrayIterator($list); if (!$itr->count()) { throw new InvalidParamException('List cannot be empty'); } while ($itr->valid()) { $file = $itr->current(); $fileId = is_int($itr->key()) ? null : $itr->key(); if (!$itr->current() instanceof $this->fileClass) { /** @var File $file */ $file = \Yii::createObject($this->fileClass, [['fileUrl' => $itr->current(), 'fileId' => $fileId]]); } if ($type === 'css') { $file->registerAsCssFile($options); } else { if ($type === 'js') { $file->registerAsJsFile($options); } } // Apply callback to each file if (is_callable($callback)) { call_user_func_array($callback, [$file->getUrl(), $options, $file->getId()]); } $itr->next(); } }
<?php //print_r(spl_classes()); ?> <?php $iterator = new ArrayIterator(array('recipe'=>'pancakes', 'egg', 'milk', 'flour')); $itCnt = $iterator->count(); echo $itCnt . PHP_EOL; $iterator->append("water"); $iterator->ksort(); while($iterator->valid()){ echo "Key : ". $iterator->key() . ", Value: " .$iterator->current() . PHP_EOL; $iterator->next(); } if($iterator->offsetExists(9)){ $iterator->seek(3); } else{ $iterator->seek($itCnt); echo $iterator->offsetGet('recipe') . PHP_EOL; } echo "[$itCnt]" . PHP_EOL; echo PHP_EOL . "Key : ". $iterator->key() . ", Value: " .$iterator->current() . PHP_EOL;
<?php $array = ['Apple', 'Microsoft', 'HP']; $iterator = new ArrayIterator($array); //echo $iterator->current(); $iterator->next(); echo $iterator->current(); // echo $iterator->count();
// example navigation array $nav = array('Home' => '/home', 'Products' => '/products', 'Company' => '/company', 'Privacy Policy' => '/privacy-policy'); // storage of output $output = new ArrayIterator(); try { // create the caching iterator of the nav array $it = new CachingIterator(new ArrayIterator($nav)); foreach ($it as $name => $url) { if ($it->hasNext()) { $output->append('<li><a href="' . $url . '">' . $name . '</a></li>'); } else { $output->append('<li class="last"><a href="' . $url . '">' . $name . '</a></li>'); } } // if we have values, output the unordered list if ($output->count()) { echo '<ul id="nav">' . "\n" . implode("\n", (array) $output) . "\n" . '</ul>'; } } catch (Exception $e) { die($e->getMessage()); } /** * Below is the same example, but prettified in a nice, extensible class * allowing you to reuse it for nav, subnav, or any time you need to * determine the last element of an array. */ class NavBuilder extends CachingIterator { /** * Override the current() method to modify the return value * for the given index.
/** * Count elements of an object * @link http://php.net/manual/en/countable.count.php * @return integer The custom count as an integer. */ public function count() { return $this->_list->count(); }
<th>Flight Name</th> <th>Source</th> <th>Destination</th> <th>Boarding Date</th> <th>Arrival Date</th> <th>Boarding Time</th> <th>Arrival Time</th> <th>Stops</th> <th>Price Rate</th> <th>Status</th> <th>#</th> </tr> <?php for ($var = 0; $var < $flightList->count(); $var++) { $flight = new Flight(); $flightList->seek($var); $flight = $flightList->current(); $checkFlight = ContextManager::$Model->flight != null ? ContextManager::$Model->flight : new Flight(); $checked = ""; if ($checkFlight->checked == true && $flight->Id == $checkFlight->Id) { //echo $flight->checked; $checked = "checked='checked'"; } $status = ""; if ($flight->status == 0 || $flight->status == '0') { $status = "passive"; } else { $status = "active"; }
} else { if ($tipo_acao == "anexar") { $file = "juntada_anexacao.rtf"; $tipo_vinc = 1; } } $iterator = new ArrayIterator(processosVinc($nuprocesso, $tipo_vinc, $auth->ID)); $cont = 0; $apensos = null; $datafile = array(); while ($iterator->valid()) { $current = $iterator->current(); $datafile['data'] = format($current['DT_INCLUSAO_FORM']); $datafile['processo'] = $current['NU_PROCESSO']; $datafile['solicitante'] = $current['SETOR']; if ($cont < $iterator->count() - 1) { $cont == 0 ? $apensos .= $current['NM_APENSO'] : ($apensos .= ", " . $current['NM_APENSO']); } else { $iterator->count() == 1 ? $apensos .= $current['NM_APENSO'] : ($apensos .= " e " . $current['NM_APENSO']); } $datafile['apensados'] = $apensos; $iterator->next(); $cont++; } $fp = fopen($dir . $file, "r"); $output = fread($fp, filesize($dir . $file)); fclose($fp); $output = str_replace("<<DATA>>", $datafile['data'], $output); $output = str_replace("<<DIRETORIA>>", $datafile['solicitante'], $output); $output = str_replace("<<NUMERO_PROCESSO>>", $datafile['processo'], $output); $output = str_replace("<<APENSADOS>>", $datafile['apensados'], $output);
<?php $ai = new ArrayIterator(array(0, 1)); var_dump($ai->count()); $ii = new IteratorIterator($ai); var_dump($ii->count());
$objPHPExcel = new PHPExcel(); // Se asignan las propiedades del libro excel. (Datos que se visualizan al dar “Clic derecho > Propiedades > Detalles”) $objPHPExcel->getProperties()->setCreator("BibliotecaFUP")->setLastModifiedBy("BibliotecaFUP")->setTitle("Reporte Excel BibliotecaFUP")->setSubject("Reporte Excel BibliotecaFUP")->setDescription("Reporte de libros")->setKeywords("reporte libros FUP")->setCategory("Reporte excel"); //Categorias $tituloReporte = "FUNDACION UNIVERSITARIA DE POPAYAN"; $subtituloReporte = "Reporte: Listado de libros"; $titulosColumnas = array('TITULO', 'VALOR', 'ADQUISICION', 'ISBN', 'RADICADO', 'FECHA INGRESO', 'COD. TOPOGRAFICO', 'SERIE', 'SEDE', 'EDITORIAL', 'AREA', 'AÑO', 'TEMAS', 'PAGINAS', 'CIUDAD', 'ACTIVO'); // Se combinan las celdas A1 hasta D1, para colocar ahí el titulo del reporte $objPHPExcel->setActiveSheetIndex(0)->mergeCells('A1:D1'); // Se agregan los titulos del reporte $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', $tituloReporte)->setCellValue('A2', $subtituloReporte)->setCellValue('A4', $titulosColumnas[0])->setCellValue('B4', $titulosColumnas[1])->setCellValue('C4', $titulosColumnas[2])->setCellValue('D4', $titulosColumnas[3])->setCellValue('E4', $titulosColumnas[4])->setCellValue('F4', $titulosColumnas[5])->setCellValue('G4', $titulosColumnas[6])->setCellValue('H4', $titulosColumnas[7])->setCellValue('I4', $titulosColumnas[8])->setCellValue('J4', $titulosColumnas[9])->setCellValue('K4', $titulosColumnas[10])->setCellValue('L4', $titulosColumnas[11])->setCellValue('M4', $titulosColumnas[12])->setCellValue('N4', $titulosColumnas[13])->setCellValue('O4', $titulosColumnas[14])->setCellValue('P4', $titulosColumnas[15]); //Se agregan los datos de los libros $i = 5; //Numero de fila donde se va a comenzar a escribir los datos $iterator = new ArrayIterator($listaLibros); if ($iterator->count() > 0) { while ($iterator->valid()) { $fechaIngreso = ""; if ($iterator->current()->getFechaIngreso() != null) { $fechaIngreso = $iterator->current()->getFechaIngreso(); } $sede = ""; if ($iterator->current()->getSede() != null) { $sede = $iterator->current()->getSede()->getDescripcion(); } $editorial = ""; if ($iterator->current()->getEditorial() != null) { $editorial = $iterator->current()->getEditorial()->getDescripcion(); } $area = ""; if ($iterator->current()->getArea() != null) {
/** * (PHP 5 >= 5.1.0)<br/> * Count elements of an object * @link http://php.net/manual/en/countable.count.php * @return int The custom count as an integer. * </p> * <p> * The return value is cast to an integer. */ public function count() { return $this->data->count(); }
/** * Returns the number of elements. * * @return integer The number of elements. */ public function count() { return $this->iterator->count(); }