$v) { if(in_array($k, $keys)) unset($arr[$k]); } return $arr; } /** * This function will remove all the specified values from an array and return the final array. * Arguments: The first argument is the array that should be edited * The arguments after the first argument is a list of values that must be removed. * Example : array_remove_value($arr,'one','two','three'); * Return : The function will return an array after deleting the said values * Link : http://www.bin-co.com/php/scripts/array_remove.php */ function array_remove_value() { $args = func_get_args(); $arr = $args[0]; $values = array_slice($args,1); foreach($arr as $k=>$v) { if(in_array($v, $values)) unset($arr[$k]); } return $arr; } /** * The index function - Created this to avoid the extra isset() check. This will return false * if the specified index of the specified function is not set. If it there, * this function will return that element. * Arguments: $array - The array in which the item must be checked for * $index - The index to be seached. * $default_value - The value that must be returned if the item is not set * Example: * if(i($_REQUEST, 'item')) { * instead of * if(isset($_REQUEST['item']) and $_REQUEST['item']) { */ function i($array, $index=false, $default_value=false) { if($index === false) { if(isset($array)) return $array; return $default_value; } if(!isset($array[$index])) return $default_value; return $array[$index]; } /// Returns a random element of an array. function any() { $arr = func_get_args(); if(count($arr) == 1) $arr = $arr[0]; return $arr[array_rand($arr)]; }