当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > array_uintersect() 函数

PHP
PHP Libxml
PHP Math
PHP Misc
PHP MySQL
PHP SimpleXML
PHP String
PHP XML
PHP Zip
PHP Mail
用PHP5的DirectoryIterators递归扫描目录
PHP 阻止SQL注入式攻击
PHP5面向对象 - 基础 - 类和对象
PHP5面向对象 - 基础 - 类的属性( public )
PHP5面向对象 - 基础 - 类的属性( private )
PHP5面向对象 - 基础 - 方法
PHP5面向对象 - 基础 - 对象的比较
php5面向对象 - 基础 - 构造函数
php5面向对象 - 基础 - 析构函数
用PHP控制用户的浏览器 - ob*函数的使用
PHP PDO 学习笔记

PHP 中的 array_uintersect() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 436 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The array_uintersect() function compares two or more arrays, in a user-made function, and returns an array containing the elements from the first array, if the user-made function allows it. The user-made function compares array values, and returns a numeric value, 0 if the returned array should contain this element.
array_uintersect()函数通过比较用户自定义函数中的两个或多个数组,找出其中相同的元素,并返回位于第一个数组中相同的元素;如果返回值设置为“return 1”,则表示返回的数组中需要包含上述那个位于第一个数组中相同的元素;如果设置为“return 0[或者是一个负数,如:-1]” ,则表示不包含该元素。

Syntax
语法

array_uintersect(array1,array2,array3...,function)

Parameter参数 Description描述
array1 Required. The first array is the array that the others will be compared with
必要参数。指定一个参与比较的基准数组
array2 Required. An array to be compared with the first array
必要参数。与数组1[array1]进行比较的数组2[array2]
array3 Optional. An array to be compared with the first array
可选参数。与数组1[array1]进行比较的数组3[array3]
function Required. The name of the user-made function
必要参数。用户自定义函数的名称


Tips and Notes
提示和注意点

Tip: You can compare the first array with one array, or as many as you like.
提示:你可以使用一个或多个数组与数组1[array1]进行比较。

Note: Only the value is used in the comparison.
注意:该函数仅对数组中的值进行比较。


Example
案例

<?php
function myfunction($v1,$v2)
{
if ($v1===$v2)	{	return 0;	}
return 1;
}
$a1=array("a"=>"Cat","b"=>"Dog","c"=>"Horse");
$a2=array(1=>"Cat",2=>"Dog",3=>"Fish");
print_r(array_uintersect($a1,$a2,"myfunction"));
?>

The output of the code above will be:
上述代码将输出下面的结果:

Array ( [a] => Cat [b] => Dog )

评论 (0) All

登陆 | 还没注册?