a::remove PHP Method

remove() static public method

Removes an element from an array
static public remove ( array $array, mixed $search, boolean $key = true ) : array
$array array The source array
$search mixed The value or key to look for
$key boolean Pass true to search for an key, pass false to search for an value.
return array The result array without the removed element
    static function remove($array, $search, $key = true)
    {
        if ($key) {
            unset($array[$search]);
        } else {
            $found_all = false;
            while (!$found_all) {
                $index = array_search($search, $array);
                if ($index !== false) {
                    unset($array[$index]);
                } else {
                    $found_all = true;
                }
            }
        }
        return $array;
    }

Usage Example

Esempio n. 1
0
 function remove($key)
 {
     return a::remove($_SESSION, $key);
 }
All Usage Examples Of a::remove