$values = array("Apple", "Banana", "Cherry", "Apple", "Grape"); $uniqueValues = t3lib_div::uniqueList($values); print_r($uniqueValues);
Array ( [0] => Apple [1] => Banana [2] => Cherry [3] => Grape )
$numbers = array(2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 20); $uniqueNumbers = t3lib_div::uniqueList($numbers); print_r($uniqueNumbers);
Array ( [0] => 2 [1] => 4 [2] => 6 [3] => 8 [4] => 10 [5] => 12 [6] => 14 [7] => 16 [8] => 18 [9] => 20 )In the above example, we have an array of numbers that includes "20" duplicated twice. The uniqueList() function removes the duplicate value of "20" from the array and returns an array with only ten elements. In summary, the t3lib_div uniqueList() function is primarily used for filtering out duplicate values from arrays and returning only the unique values. It is a part of the TYPO3 CMS core library.