lithium\util\Collection::offsetUnset PHP Method

offsetUnset() public method

Unsets an offset.
public offsetUnset ( string $offset )
$offset string The offset to unset.
    public function offsetUnset($offset)
    {
        prev($this->_data);
        if (key($this->_data) === null) {
            $this->rewind();
        }
        unset($this->_data[$offset]);
    }

Usage Example

Example #1
0
 /**
  * Tests the `ArrayAccess` interface implementation for manipulating values by direct offsets.
  *
  * @return void
  */
 public function testArrayAccessOffsetMethods()
 {
     $collection = new Collection(array('data' => array('foo', 'bar', 'baz' => 'dib')));
     $this->assertTrue($collection->offsetExists(0));
     $this->assertTrue($collection->offsetExists(1));
     $this->assertTrue($collection->offsetExists('0'));
     $this->assertTrue($collection->offsetExists('baz'));
     $this->assertFalse($collection->offsetExists('2'));
     $this->assertFalse($collection->offsetExists('bar'));
     $this->assertFalse($collection->offsetExists(2));
     $this->assertEqual('foo', $collection->offsetSet('bar', 'foo'));
     $this->assertTrue($collection->offsetExists('bar'));
     $this->assertNull($collection->offsetUnset('bar'));
     $this->assertFalse($collection->offsetExists('bar'));
 }
All Usage Examples Of lithium\util\Collection::offsetUnset