/** * (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); }
private function clean(\ArrayIterator $files) { foreach ($files as $key => $value) { if (is_null($value[0])) { $files->offsetUnset($key); continue; } } return $files; }
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); } } } } }
/** * 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; }
public function offsetUnset($index) { $this->collection->offsetUnset($index); parent::offsetUnset($index); $this->refreshPositions(); }
/** * Unset value at offset * * @param string $index */ public function offsetUnset($index) { parent::offsetExists($index) && parent::offsetUnset($index); }
/** */ public function offsetUnset($offset) { if (!is_null($offset = $this->_getRealOffset($offset))) { parent::offsetUnset($offset); } }
/** * \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); }
public function offsetUnset($k) { return parent::offsetUnset($this->normalize($k)); }
<?php $object = new ArrayIterator(); $object->append(1); foreach ($object as $key => $value) { $object->offsetUnset($key); } ?> ===DONE===
/** * Offset to unset * @param string $offset * @return void * @throws CollectionException */ public function offsetUnset($offset) { $this->specsIterator->offsetUnset($offset); }
/** * @param mixed|string $index * * @author Yohann Marillet */ public function offsetUnset($index) { $offset = $this->getKey($index); parent::offsetUnset($offset); }
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();
public function offsetUnset($offset) { $name = $this->_normalizeHeaderName($offset); unset($this->_fields[$name]); parent::offsetUnset($name); }