note 69712 deleted from function.in-array by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: nongjianz at yahoo dot com 

----

in_array does not work for this case:

If all items of an array as elements (not as an array) are in another array. For example:

$arr1 = array("aaa", "bbb", "ccc", "ddd");
$arr2 = array("aaa", "bbb");

The following function is a solution to work it out:
<?
function arrElement_in_array($arr2, $arr1){
	foreach($arr2 as $v){
		if(in_array($v, $arr1)){
           $count++; 
		}
	}
	//if all elements of arr2 are in arr1
	if($count==count($arr2)){
		return true;
	}
}
?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.