Array in Array

A Simple function see if an array is contained within another array

<?
function array_in_array($needle, $haystack) {
	if(count($haystack) > 0) {
		foreach ($haystack as $key => $value) {
			if ($needle == $value)
				return true;
		}
	}
	
	return false;
}
?>

Usage

Pass the array you want to check for and the array you want to search for it in as $needle and $haystack respectively


Comments

Add your comment