function array_remove(array $set, $path) { return Hash::remove($set, $path); }
/** * Remove a parameter by key. * * @uses Titon\Utility\Hash * * @param string $key * @return $this */ public function remove($key) { $this->_data = Hash::remove($this->_data, $key); return $this; }
/** * Remove a value from the config. * * @uses Titon\Utility\Hash * * @param string $key */ public static function remove($key) { static::$_config = Hash::remove(static::$_config, $key); }
/** * Test that remove() deletes elements in an array based on the dot notated path. */ public function testRemove() { $data = $this->expanded; $match = $data; unset($match['boolean']); $data = Hash::remove($data, 'boolean'); $this->assertEquals($match, $data); unset($match['one']['depth']); $data = Hash::remove($data, 'one.depth'); $this->assertEquals($match, $data); unset($match['one']['two']['depth']); $data = Hash::remove($data, 'one.two.depth'); $this->assertEquals($match, $data); unset($match['one']['two']['three']['depth'], $match['one']['two']['three']['zero'], $match['one']['two']['three']['null']); $data = Hash::remove($data, 'one.two.three.depth'); $data = Hash::remove($data, 'one.two.three.zero'); $data = Hash::remove($data, 'one.two.three.null'); $this->assertEquals($match, $data); unset($match['one']['two']['three']['four']['five']['six']['seven']['key']); $data = Hash::remove($data, 'one.two.three.four.five.six.seven.key'); $this->assertEquals($match, $data); foreach (array(true, false, null, 123, 'foo') as $type) { $data = Hash::remove($data, $type); $this->assertEquals($match, $data); } $data = Hash::remove($data, 'a.fake.path'); $this->assertEquals($match, $data); }