1,把数组转成字符串用逗号分开
implode ( ",", $array);
2,多个数组比较,去除相同的元素,返回不同的元素
array_diff(array1,array2,.....);
例如
$a = array(1,2,3,4,5,6);
$b = array(2,3);
$c = array(4,5);
则 $d =array_diff($a,$b,$c)值为 array(1,6);
print_r($d);
Array ( [0] => 1 [5] => 6 )
比较后的数组索引是无规则,重新排列数组索引
$diffarray = array();
foreach ( $diff as $v ) {
$diffarray [] = $v;
}
3,删除数组中的元素
$movearray = array('a','b','c');
$disption = array_search("a",$movearray );
array_splice($movearray ,$disption,1);
print_r($movearray );
Array ( [0] => b [1] => c )