function will return an array with unique values and will preserve the keys.
<?php
$my_array = array(1, 2, 3, 3, 4, 4, 1, 5, 6, 6, 7);
$my_unique_array = array_unique($my_array);
echo '<pre>';
print_r($my_unique_array);
echo '</pre>';
/*
OUTPUT:
Array
(
[0] => 1
[1] => 2
[2] => 3
[4] => 4
[7] => 5
[8] => 6
[10] => 7
)
*/
?>
No comments:
Post a Comment