本文整理匯總了PHP中ArrayIterator::offsetUnset方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayIterator::offsetUnset方法的具體用法?PHP ArrayIterator::offsetUnset怎麽用?PHP ArrayIterator::offsetUnset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ArrayIterator
的用法示例。
在下文中一共展示了ArrayIterator::offsetUnset方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: offsetUnset
/**
* (PHP 5 >= 5.0.0)<br/>
* Unset value for an offset
*
* @link http://php.net/manual/en/arrayiterator.offsetunset.php
*
* @param string $index <p>
* The offset to unset.
* </p>
*
* @throws Exception\Collection When the collection has been marked as read-only
*/
public function offsetUnset($index)
{
if ($this->isReadOnly() === true) {
throw Exception\Collection::readOnly(get_class($this));
}
parent::offsetUnset($index);
}
示例2: clean
private function clean(\ArrayIterator $files)
{
foreach ($files as $key => $value) {
if (is_null($value[0])) {
$files->offsetUnset($key);
continue;
}
}
return $files;
}
示例3: offsetUnset
public function offsetUnset($name)
{
if (!is_array($name)) {
return parent::offsetUnset($name);
} else {
$key = array_shift($name);
if (sizeof($name) == 0) {
return parent::offsetUnset($key);
} else {
if (parent::offsetExists($key)) {
$object = parent::offsetGet($key);
if (is_a($object, 'MutliDimArray')) {
$object->offsetUnset($name);
if ($object->sizeof() == 0) {
parent::offsetUnset($key);
}
} else {
parent::offsetUnset($key);
}
}
}
}
}
示例4: offsetUnset
/**
* Unset values from an offset or offsets
*
* @param string|array $index Offsets to remove
*
* @return Collection
*/
public function offsetUnset($index)
{
$index = is_array($index) ? $index : (array) $index;
foreach ($index as $key) {
parent::offsetUnset($key);
}
return $this;
}
示例5: offsetUnset
public function offsetUnset($index)
{
$this->collection->offsetUnset($index);
parent::offsetUnset($index);
$this->refreshPositions();
}
示例6: offsetUnset
/**
* Unset value at offset
*
* @param string $index
*/
public function offsetUnset($index)
{
parent::offsetExists($index) && parent::offsetUnset($index);
}
示例7: offsetUnset
/**
*/
public function offsetUnset($offset)
{
if (!is_null($offset = $this->_getRealOffset($offset))) {
parent::offsetUnset($offset);
}
}
示例8: offsetUnset
/**
* \WP_Widget::update_callback(): unset($all_instances[$number]);
* \WP_Widget::get_settings(): unset($settings['_multiwidget'], $settings['__i__']);
*
* @param int|string $key Array key.
*/
public function offsetUnset($key)
{
if ('_multiwidget' === $key || '__i__' === $key) {
return;
}
$key = filter_var($key, FILTER_VALIDATE_INT);
if ($key < 2) {
return;
}
$this->unset_widget_numbers[] = $key;
parent::offsetUnset($key);
}
示例9: offsetUnset
public function offsetUnset($k)
{
return parent::offsetUnset($this->normalize($k));
}
示例10: ArrayIterator
<?php
$object = new ArrayIterator();
$object->append(1);
foreach ($object as $key => $value) {
$object->offsetUnset($key);
}
?>
===DONE===
示例11: offsetUnset
/**
* Offset to unset
* @param string $offset
* @return void
* @throws CollectionException
*/
public function offsetUnset($offset)
{
$this->specsIterator->offsetUnset($offset);
}
示例12: offsetUnset
/**
* @param mixed|string $index
*
* @author Yohann Marillet
*/
public function offsetUnset($index)
{
$offset = $this->getKey($index);
parent::offsetUnset($offset);
}
示例13: ArrayIterator
try {
$object = new ArrayIterator($array);
// 判斷第二個節點是否存在
if ($object->offsetExists(2)) {
// 給第二個節點賦新值
$object->offsetSet(2, 'value2_1');
}
// 在數組最後插入新值
$object->append('value_6');
// 自然排序排序 natsort(): 數組進行自然排序; natcasesort():對數組進行自然排序,並不區分大小寫
// uasort(): uksort(): 通過在參數中傳遞已定義的排序方式進行排序;
$object->natsort();
// 檢查key為3所對應的值
$object->offsetGet(3);
// 銷毀key為3的值
$object->offsetUnset(3);
// 指針跳轉到第5個節點
$object->seek(4);
// foreach 循環
/**
* 如下的寫法經調試出現了一個bug。
* 當在循環中進行offsetUnset時,此時,當前指針會回跳會第一個節點,即$object->key()的值為0,但是此時循環的key值和value值並沒有變,依然是3=>value4。
* 而再次foreach循環之前,$object->key()值為0.循環後,$object->key()為1,所有,此時循環重複值。
*/
foreach ($object as $key => $value) {
echo '<li>' . $key . '=>' . $value . '</li>' . "\n";
}
// while 循環
$object->rewind();
while ($object->valid()) {
echo $object->current();
示例14: offsetUnset
public function offsetUnset($offset)
{
$name = $this->_normalizeHeaderName($offset);
unset($this->_fields[$name]);
parent::offsetUnset($name);
}