php數(shù)組刪除相同的值
在php中可以通過“array_unique()”函數(shù),來實現(xiàn)去除數(shù)組中的重復(fù)值,該函數(shù)的用法為“array_unique($array)”,其參數(shù)$array表示為要去除重復(fù)值的數(shù)組,該函數(shù)的返回值為去除重復(fù)值后的數(shù)組。
array_unique示例
<?php $input = array("a" => "green", "red", "b" => "green", "blue", "red"); $result = array_unique($input); print_r($result); ?>
輸出結(jié)果:
Array ( [a] => green [0] => red [1] => blue )