Search code examples
phpunique

How to implement a php Function which accepts a single array of integers and returns the unique integers separated by commas?


How to implement a php Function which accepts a single array of integers and returns the unique integers separated by commas?

Eg: GetUniqueOnes($arr)

$arrr = array(34,54,68,141,151,54,151,54)

should return 34,54,68,141,151,161


Solution

  • $string = join(',', array_unique($array));
    

    No need for a function;