Home > Backend Development > PHP Tutorial > php删除数组中指定值的元素

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

WBOY
Release: 2016-06-23 13:57:03
Original
867 people have browsed it

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;}
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template