function testSeek() { $iterator = new ArrayIterator([0, 5, 2, 6]); $iterator->rewind(); $iterator->seek(3); $this->assertEquals(6, $iterator->current()); $iterator->seek(1); $this->assertEquals(5, $iterator->current()); $iterator->seek(2); $this->assertEquals(2, $iterator->current()); $iterator->seek(0); $this->assertEquals(0, $iterator->current()); $iterator->seek(3); $this->assertEquals(6, $iterator->current()); }
/** * Replace portion of the string * * @deprecated * * @param integer $index * @param string $value * @param integer $start * @param integer $length * * @access public * @return void */ public function ReplaceChunk($index, $value, $start = 0, $length = null) { if (null !== $length) { $this->length = $length; } switch (true) { case is_string($value): $this->temp_string = new \ArrayIterator(str_split($value)); if (null === $length) { $this->length = strlen($value); } break; case $value instanceof \ArrayIterator: $this->temp_string = $value; if (null === $length) { $this->length = $value->count(); } break; case is_array($value): $this->temp_string = new \ArrayIterator($value); if (null === $length) { $this->length = count($value); } break; default: throw new \Exception('Invalid data type', 101); } $this->temp_string->seek($start); for ($i = $start; $i < $this->length; $i++) { $this->offsetSet($index, $this->temp_string->current()); $index++; $this->temp_string->next(); } $this->temp_string = null; }
/** * (PHP 5 >= 5.1.0)<br/> * Seeks to a position * @link http://php.net/manual/en/seekableiterator.seek.php * @param int $position <p> * The position to seek to. * </p> * @return void * @throws MIMException */ public function seek($position) { if ($position == NULL) { throw new MIMException("Can't seek to a NULL position", 550); } $this->iterator->seek($position); }
/** * Gets item by it`s position * @param integer $position * @return mixed */ private function getByPosition($position) { $key = $this->_list->key(); $this->_list->seek($position); $item = $this->_list->current(); $this->_list->seek($key); return $item; }
function omg() { $itr = new ArrayIterator($vals); $itr->seek($random); $city = $itr->current(); $country = $itr->key(); echo $country; return $city; }
/** * nastaví podle vnitřního ukazatele */ public function seek($pointer) { $pointer = (int) $pointer; try { parent::seek($pointer); $this->pointer = $pointer; } catch (\OutOfBoundsException $e) { if ($this->pointer != -1) { throw $e; } } }
/** * @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; }
</th> <th><?php echo gettext('Status'); ?> </th> <th><?php echo gettext('Planned'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody item_relation_values" > <?php $count = 0; $item_relation_object_ai = new ArrayIterator($item_relation_object); $item_relation_object_ai->seek($position); while ($item_relation_object_ai->valid()) { $inv_item_relation = $item_relation_object_ai->current(); if (!empty(${$class}->from_item_id_m)) { $from_item_i = item::find_by_item_id_m(${$class}->from_item_id_m); if ($from_item_i) { ${$class}->from_item_number = $from_item_i->item_number; } else { ${$class}->from_item_number = null; } } else { ${$class}->from_item_number = null; } if (!empty(${$class}->to_item_id_m)) { $to_item_i = item::find_by_item_id_m(${$class}->to_item_id_m); if ($to_item_i) {
<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"; } $name = $aplanes->GetName($flight->planeID); echo "<tr>\r\n <td>{$var}</td>\r\n <td>{$name}</td>\r\n <td>{$flight->from}</td>\r\n <td>{$flight->to}</td>\r\n <td>{$flight->deptureDate}</td>\r\n <td>{$flight->landindDate}</td>\r\n <td>{$flight->boardingTime}</td>\r\n <td>{$flight->Landingtime}</td>\r\n <td>{$flight->stops}</td>\r\n <td>{$flight->ticketPrice}</td>\r\n <td>{$flight->seats}</td>\r\n <td>{$status}</td>\r\n <td><input type='checkbox' value='{$flight->Id}' name='chkflights[]' {$checked} ></td>\r\n </tr>\r\n ";
</th> <th><?php echo gettext('Task Status'); ?> </th> <th><?php echo gettext('CIP Asset'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody"> <?php $count = 0; $prj_project_line_object_ai = new ArrayIterator($prj_project_line_object); $prj_project_line_object_ai->seek($position); while ($prj_project_line_object_ai->valid()) { $prj_project_line = $prj_project_line_object_ai->current(); ?> <tr class="prj_project_line<?php echo $count; ?> "> <td><?php $f->seq_field_d($count); ?> </td> <td><?php echo $f->text_field('task_number2', ${$class_second}->task_number, '', '', 'task_number'); ?>
<th><?php echo gettext('Quantity'); ?> #</th> <th><?php echo gettext('Line Amount'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody pos_transaction_line_values" > <?php // pa($pos_transaction_line_object); $count = 0; $pos_transaction_line_object_ai = new ArrayIterator($pos_transaction_line_object); $pos_transaction_line_object_ai->seek($position); while ($pos_transaction_line_object_ai->valid()) { $pos_transaction_line = $pos_transaction_line_object_ai->current(); ?> <tr class="pos_transaction_line<?php echo $count; ?> "> <td><?php $f->text_field_wid2('item_number'); ?> </td> <td><?php echo $f->number_field('unit_price', ${$class_second}->unit_price, '', '', 'medium'); ?>
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; }
?> <?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; var_dump(iterator_count($iterator)); ?>
</th> <th><?php echo gettext('Start Date'); ?> </th> <th><?php echo gettext('End Date'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody"> <?php $linecount = 0; $option_line_object_ai = new ArrayIterator($option_line_object); $option_line_object_ai->seek($position); while ($option_line_object_ai->valid()) { $option_line = $option_line_object_ai->current(); ?> <tr class="option_line<?php echo $linecount; ?> "> <td><?php $f->seq_field_d($linecount); ?> </td> <td><?php echo form::status_field($option_line->status); ?>
#</th> <th><?php echo gettext('Description'); ?> </th> <th><?php echo gettext('Status'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody default_account_values" > <?php $count = 0; $default_account_object_ai = new ArrayIterator($default_account_object); $default_account_object_ai->seek($position); while ($default_account_object_ai->valid()) { $prj_default_account = $default_account_object_ai->current(); ?> <tr class="prj_default_account<?php echo $count; ?> "> <td><?php echo ino_inline_action(${$class}->prj_default_account_id, array('prj_project_type_header_id' => $prj_project_type_header_id_h)); ?> </td> <td><?php form::number_field_drs('prj_default_account_id');
</th> <th><?php echo gettext('Communication Details'); ?> </th> <th><?php echo gettext('Projects'); ?> #</th> </tr> </thead> <tbody class="form_data_line_tbody employee_experience_values" > <?php $count = 0; $employee_experience_object_ai = new ArrayIterator($employee_experience_object); $employee_experience_object_ai->seek($position); while ($employee_experience_object_ai->valid()) { $hr_employee_experience = $employee_experience_object_ai->current(); ?> <tr class="hr_employee_experience<?php echo $count; ?> "> <td><?php $f->seq_field_d($count); ?> </td> <td><?php $f->text_field_wid('last_drawn_salary'); ?>
<?php $it = new ArrayIterator(range(0, 10)); var_dump($it->count()); $it->seek(5); var_dump($it->current()); $it->seek(4); var_dump($it->current()); try { $it->seek(-1); var_dump($it->current()); } catch (Exception $e) { echo $e->getMessage() . "\n"; } try { $it->seek(12); var_dump($it->current()); } catch (Exception $e) { echo $e->getMessage() . "\n"; } $pos = 0; foreach ($it as $v) { $it->seek($pos++); var_dump($v); } ?> ===DONE=== <?php exit(0);
</th> <th><?php echo gettext('Compensation ELement'); ?> #</th> <th><?php echo gettext('Amount'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody payslip_line_values" > <?php $count = 0; $hr_payslip_line_object_ai = new ArrayIterator($hr_payslip_line_object); $hr_payslip_line_object_ai->seek($position); while ($hr_payslip_line_object_ai->valid()) { $hr_payslip_line = $hr_payslip_line_object_ai->current(); ?> <tr class="hr_payslip_line<?php echo $count; ?> "> <td> <?php echo ino_inline_action($hr_payslip_line->hr_payslip_line_id, array('hr_payslip_header_id' => ${$class}->hr_payslip_header_id)); ?> </td> <td><?php $f->text_field_wid2sr('hr_payslip_line_id');
private function extractHierarchy() { $implements = array(); $extends = array(); $extractor = function ($iterator, $callback) { $className = ''; $iterator->seek($iterator->key() + 1); while ($iterator->valid()) { $token = $iterator->current(); if (is_string($token)) { if (preg_match('/\\s?,\\s?/', $token)) { $callback(trim($className)); $className = ''; } else { if ($token == '{') { $callback(trim($className)); return; } } } switch ($token[0]) { case T_NS_SEPARATOR: $className .= '\\'; break; case T_STRING: $className .= $token[1]; break; case T_IMPLEMENTS: case T_EXTENDS: $callback(trim($className)); $iterator->seek($iterator->key() - 1); return; } $iterator->next(); } }; $tokens = token_get_all("<?php\n" . trim($this->getPhpCode())); $iterator = new ArrayIterator($tokens); while ($iterator->valid()) { $token = $iterator->current(); if (is_string($token)) { $iterator->next(); continue; } switch ($token[0]) { case T_CLASS: case T_INTERFACE: $iterator->seek($iterator->key() + 2); $tk = $iterator->current(); $this->name = $tk[1]; break; case T_IMPLEMENTS: $extractor($iterator, function ($fqn) use(&$implements) { $implements[] = $fqn; }); break; case T_EXTENDS: $extractor($iterator, function ($fqn) use(&$extends) { $extends[] = $fqn; }); break; } $iterator->next(); } $this->implements = $this->guessFQN($implements); $this->extends = $this->guessFQN($extends); }
<th>Item</th> <th>New Revision</th> <th>Item Description</th> <?php foreach ($template_lines_ia as $fields) { if ($no_of_fields_in_tab >= NO_OF_FIELDS_IN_TAB) { break; } echo '<th>' . ucwords(str_replace('_', ' ', $fields->field_name)) . '</th>'; $no_of_fields_in_tab++; } } else { echo '<th>Seq#</th>'; $pos = ($tlc - 2) * NO_OF_FIELDS_IN_TAB + (NO_OF_FIELDS_IN_TAB - NO_OF_SEEDED_FIELDS); if (!empty($template_lines)) { $template_lines_ia->seek($pos); while ($template_lines_ia->valid()) { if ($no_of_fields_in_tab >= NO_OF_FIELDS_IN_TAB) { break; } echo '<th>' . ucwords(str_replace('_', ' ', $template_lines_ia->current()->field_name)) . '</th>'; $no_of_fields_in_tab++; $template_lines_ia->next(); } } } ?> </tr> </thead> <tbody class="form_data_line_tbody"> <?php
</th> <th><?php echo gettext('Period Name'); ?> </th> <th><?php echo gettext('Description'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody hr_payroll_schedule_values" > <?php $count = 0; $hr_payroll_schedule_object_ai = new ArrayIterator($hr_payroll_schedule_object); $hr_payroll_schedule_object_ai->seek($position); while ($hr_payroll_schedule_object_ai->valid()) { $hr_payroll_schedule = $hr_payroll_schedule_object_ai->current(); ?> <tr class="hr_payroll_schedule<?php echo $count; ?> "> <td><?php echo ino_inline_action($hr_payroll_schedule->hr_payroll_schedule_id, array('hr_payroll_id' => ${$class}->hr_payroll_id)); ?> </td> <td><?php $f->text_field_d2sr('hr_payroll_schedule_id'); ?> </td>
</th> <th><?php echo gettext('ABC Class'); ?> </th> <th><?php echo gettext('Comments'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody inv_abc_assignment_line_values" > <?php $count = 0; $inv_abc_assignment_line_object_ai = new ArrayIterator($inv_abc_assignment_line_object); $inv_abc_assignment_line_object_ai->seek($position); while ($inv_abc_assignment_line_object_ai->valid()) { $inv_abc_assignment_line = $inv_abc_assignment_line_object_ai->current(); ?> <tr class="inv_abc_assignment_line<?php echo $count; ?> "> <td> <?php echo ino_inline_action(${$class_second}->inv_abc_assignment_line_id, array('inv_abc_assignment_header_id' => ${$class}->inv_abc_assignment_header_id)); ?> </td> <td><?php form::number_field_wid2sr('inv_abc_assignment_line_id', 'always_readonly');
</th> <th><?php echo __('Final Amount'); ?> </th> <th><?php echo __('No Of Labels'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody pos_barcode_list_line_values" > <?php $count = 0; $pos_barcode_list_line_object_ai = new ArrayIterator($pos_barcode_list_line_object); $pos_barcode_list_line_object_ai->seek($position); while ($pos_barcode_list_line_object_ai->valid()) { $pos_barcode_list_line = $pos_barcode_list_line_object_ai->current(); ?> <tr class="pos_barcode_list_line<?php echo $count; ?> "> <td> <?php echo ino_inline_action(${$class_second}->pos_barcode_list_line_id, array('pos_barcode_list_header_id' => ${$class}->pos_barcode_list_header_id)); ?> </td> <td><?php form::number_field_wid2sr('pos_barcode_list_line_id');
</th> <th><?php echo gettext('Status'); ?> </th> <th><?php echo gettext('Tax Region'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody sales_region_values" > <?php $count = 0; $sales_region_object_ai = new ArrayIterator($sales_region_object); $sales_region_object_ai->seek($position); while ($sales_region_object_ai->valid()) { $ar_sales_region = $sales_region_object_ai->current(); ?> <tr class="ar_sales_region<?php echo $count; ?> "> <td><?php $f->seq_field_d($count); ?> </td> <td><?php $f->text_field_wid('description', 'dontCopy'); ?>
</th> <th><?php echo __('Rate Percentage'); ?> </th> <th><?php echo __('Description'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody fa_depreciation_method_rate_values" > <?php $count = 0; $fa_depreciation_method_rate_object_ai = new ArrayIterator($fa_depreciation_method_rate_object); $fa_depreciation_method_rate_object_ai->seek($position); while ($fa_depreciation_method_rate_object_ai->valid()) { $fa_depreciation_method_rate = $fa_depreciation_method_rate_object_ai->current(); ?> <tr class="fa_depreciation_method_rate<?php echo $count; ?> "> <td><?php echo ino_inline_action(${$class}->fa_depreciation_method_id, array('fa_depreciation_method_rate_id' => $fa_depreciation_method_rate->fa_depreciation_method_rate_id)); ?> </td> <td><?php form::number_field_wid2sr('fa_depreciation_method_rate_id'); ?>
/** * 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; } } } }
</th> <th><?php echo gettext('Subinventory'); ?> </th> <th><?php echo gettext('Locator'); ?> </th> </tr> </thead> <tbody class="form_data_line_tbody inv_count_schedule_values" > <?php $count = 0; $inv_count_schedule_object_ai = new ArrayIterator($inv_count_schedule_object); $inv_count_schedule_object_ai->seek($position); while ($inv_count_schedule_object_ai->valid()) { $inv_count_schedule = $inv_count_schedule_object_ai->current(); ?> <tr class="inv_count_schedule<?php echo $count; ?> "> <td> <?php echo ino_inline_action(${$class_second}->inv_count_schedule_id, array('inv_count_header_id' => ${$class}->inv_count_header_id)); ?> </td> <td><?php form::number_field_wid2sr('inv_count_schedule_id');
</thead> <tbody class="form_data_line_tbody cart_values" > <?php if (empty($cart_object)) { // pa($cart_object); $total_amount = $tax_amount = 0; echo '<div class="alert alert-danger" role="alert"> <strong>Cart Empty</strong> Please select any product to proceed further. </div>'; } else { $count = 1; $total = 0; $tax_p = 0; $precision = 2; $cart_object_ai = new ArrayIterator($cart_object); $cart_object_ai->seek($position); $curr = 'USD'; while ($cart_object_ai->valid()) { $ec_user_cart = $cart_object_ai->current(); ?> <tr class="ec_cart<?php echo $count; ?> "> <td><?php echo $count; ?> </td> <td><?php echo $ec_user_cart->product_name;
/** * Seek to a given position in the iterator. * * @param type $position */ public function seek($position) { $this->iterator->seek($position); }