/** * @param int $offset */ public function offsetUnset($offset) { if (!$this->offsetExists($offset)) { throw new \InvalidArgumentException('Offset does not exist'); } $this->set->offsetUnset($offset); }
/** * Unset collection item. * * @param int $index */ public function offsetUnset($index) { $this->changed = true; parent::offsetUnset($index); }
public function offsetUnset($n) { echo "A::offsetUnset\n"; return parent::offsetUnset($n); }
// 获得当前节点 $array->current(); // next() // 指针移动到下一个节点 $array->next(); // setSize(int $size) // 重新设置阵列数组的大小 $array->setSize(10); // getSize() // 获得阵列数组的大小 $array->getSize(); // offsetExists(int $index) // 判断该索引是否存在值,返回boolean $array->offsetExists(3); // offsetGet(int $index) // 获得该索引对应的值 $array->offsetGet(3); // offsetSet(int $index, mixed $value) // 设置该索引对应的值 $array->offsetSet(6, 'value3'); // offsetUnset(int $index) // 删除该索引对应的值 $array->offsetUnset(6); // toArray() // 将阵列转化成php数组 // output: Array ( [0] => [1] => 2 [2] => [3] => value2 [4] => [5] => [6] => [7] => [8] => [9] => ) $php_array = $array->toArray(); // fromArray($php_array) // 将php数组转化成阵列 // output: SplFixedArray Object ( [0] => [1] => 2 [2] => [3] => value2 [4] => [5] => [6] => [7] => [8] => [9] => ) $spl_array = SplFixedArray::fromArray($php_array);
<?php $array = new SplFixedArray(5); $a = $array->offsetUnset(); if (is_null($a)) { echo 'PASS'; }
<?php // Create a fixed array $fixedArray = new SplFixedArray(5); // Fill it up for ($i = 0; $i < 5; $i++) { $fixedArray[$i] = "PHPNW Testfest"; } // remove an item $fixedArray->offsetUnset("4"); var_dump($fixedArray);