本文整理汇总了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);
}