Home  >  Article  >  Backend Development  >  php剔除数组中指定值的元素

php剔除数组中指定值的元素

WBOY
WBOYOriginal
2016-06-13 11:57:261140browse

php删除数组中指定值的元素

php删除数组中指定值的元素

/** * 删除数组中指定值的元素 * @author: ibrahim * @param array $arr 数组 * @param string $val 值 * @return boolean */function array_del(&$arr,$val){	if( empty($val) ) return false;	$key = array_search($val,$arr);	$keys= array_keys($arr);	$position = array_search($key,$keys);	if( false !== $position){		$r = array_splice($arr,$position,1);		return true;	}	return false;}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn