Nisses blog

Slå mig, älska mig

Archive for August, 2009

A usefull function in PHP

I’ve came across a problem where I don’t want any duplicates in an array. I’m not that familiar with the functions PHP have for arrays. So I Googled for some answers and found out that there is a neat function ready.
It’s called array_unique.

$input = array("a" => "green", "red", "b" => "green", "blue", "red");
print_r($input);

Will produce the following result.

Array
(
    [a] => green
    [0] => red
    [1] => blue
)

More on array_unique

posted by Nisse in Technical and have No Comments