function remove_values($arr){
$_a = array();
while(list($key,$val) = each($arr)){
$_a[$val] = 1;
}
return array_keys($_a);
}
i can’t follow the above function well.i don’t know what’s the effect of $_a[$val] = 1; anyone can explain it to me thank you
Well all this does is to insert the value into the key of an array. Since all keys are unique in an array, you will remove all duplicates.
array_keys()simply gives back that array in it’s ordinary form.Example:
gives
which results in
since “red” can only be a keyvalue once.