remove() public static méthode

Removes an element from an array as defined by $path.
public static remove ( mixed $list, mixed $path = null ) : array
$list mixed From where to remove.
$path mixed A dot-delimited string.
Résultat array Array with `$path` removed from its value.
Exemple #1
0
 /**
  * Delete value from the session
  *
  * @param string $key The key to be deleted
  * @param array $options Options array. Not used for this adapter method.
  * @return closure Function returning boolean `true` if the key no longer exists
  *         in the session, `false` otherwise
  */
 public static function delete($key, array $options = array())
 {
     if (!static::isStarted() && !static::_start()) {
         throw new RuntimeException("Could not start session.");
     }
     $class = __CLASS__;
     return function ($self, $params) use($class) {
         $key = $params['key'];
         $class::overwrite($_SESSION, Set::remove($_SESSION, $key));
         return !Set::check($_SESSION, $key);
     };
 }
Exemple #2
0
 /**
  * Delete value from the session
  *
  * @param string $key The key to be deleted
  * @param array $options Options array. Not used for this adapter method.
  * @return closure Function returning boolean `true` if the key no longer exists
  *		   in the session, `false` otherwise
  */
 public function delete($key, array $options = array())
 {
     if (!$this->isStarted() && $this->_startup() === false) {
         throw new RuntimeException("Could not start session");
     }
     $class = get_called_class();
     return function ($self, $params) use($class) {
         if (!isset($_SESSION)) {
             return false;
         }
         $key = $params['key'];
         $class::overwrite($_SESSION, Set::remove($_SESSION, $key));
         return !Set::check($_SESSION, $key);
     };
 }
Exemple #3
0
	public function testInsertAndRemoveWithFunkyKeys() {
		$set = Set::insert(array(), 'Session Test', "test");
		$result = Set::extract($set, '/Session Test');
		$this->assertEqual($result, array('test'));

		$set = Set::remove($set, 'Session Test');
		$this->assertFalse(Set::check($set, 'Session Test'));

		$this->assertTrue($set = Set::insert(array(), 'Session Test.Test Case', "test"));
		$this->assertTrue(Set::check($set, 'Session Test.Test Case'));
	}
Exemple #4
0
 /**
  * Delete value from the session
  *
  * @param string $key The key to be deleted.
  * @param array $options Options array. Not used for this adapter method.
  * @return \Closure Function returning boolean `true` if the key no longer
  *         exists in the session, `false` otherwise
  */
 public function delete($key, array $options = array())
 {
     if (!$this->isStarted() && !$this->_start()) {
         throw new RuntimeException('Could not start session.');
     }
     $self = $this;
     return function ($class, $params) use($self) {
         $key = $params['key'];
         $self->overwrite($_SESSION, Set::remove($_SESSION, $key));
         return !Set::check($_SESSION, $key);
     };
 }