PHP Ds\Set Functions Complete Reference Last Updated : 25 Jan, 2023 Comments Improve Suggest changes Like Article Like Report Set is the collection of unique values. The implementation of Ds\Set is similar to the Ds\Map which creates a hash table. The values of Ds\Set are used as key and the mapped values are ignored. Requirements: PHP 7 is required for both extension and the compatibility polyfill. Installation: The easiest way to install data structure by using the PECL extension. pecl install ds Syntax: public Ds\Set::functionName() Example: Below programs illustrate the Ds\Set::count() function: PHP <?php // Declare new Set $set = new \Ds\Set([10, 15, 21]); // Display the Set element var_dump($set); // Display count of elements // present in the Set echo "Count is : "; print_r($set->count()); ?> Output: object(Ds\Set)#1 (3) { [0]=> int(10) [1]=> int(15) [2]=> int(21) } Count is : 3 Complete list of data structure DS\Set: Functions Description add()It is used to add values to the set.allocate()Allocate memory for required capacity.capacity()Return the capacity of the set.clear()Remove all values from the set.__construct()Create new instance of set.contains()Check the given value exists in the set or not.copy()Return the copy of the set element.count()Count the number of values present in the Set.diff()Create a set that contains the elements of the first set which are not present in the second set.filter()Create new set using filter function.first()Returns the first element of the Set.get()Get a value from the Set instance. intersect()Create a new set that contains the intersection of two sets.isEmpty()Check whether a set is empty or not.join()It is used to join all values as stringlast()Return the last element from the Set instance.merge()Returns a set after adding all given values to the set.reduce()Set to a single value by applying operations using the callback function.remove()Remove specific values from a Set instance..reverse()Reverse the order of elements present in the Set instance.reversed()Create a copy of the original Set with values arranged in reverse order.slice()Return the sub-set of a given range.sort()Sort the elements of a specified Set instance according to the values.sorted()Return a sorted copy of a given set. sum()Find the sum of all of the elements present in a Set.toArray()Convert the Set into an associative array.union()Create a new set that contains the union of two setsxor()Create a new set that contains the value either in the first set or second set but not both. Comment More infoAdvertise with us Next Article PHP DOM Functions Complete Reference S Sabya_Samadder Follow Improve Article Tags : Web Technologies PHP PHP-ds_set Similar Reads PHP DsSet Functions Complete Reference Set is the collection of unique values. The implementation of Ds\Set is similar to the Ds\Map which creates a hash table. The values of Ds\Set are used as key and the mapped values are ignored. Requirements: PHP 7 is required for both extension and the compatibility polyfill. Installation: The easie 2 min read PHP DOM Functions Complete Reference PHP DOM extension is used to operate on XML documents using DOM API. The DOM extension uses UTF-8 encoding. The Complete list of PHP DOM Functions are listed below: DOMAttr PHP DOMAttr __construct() FunctionPHP DOMAttr isId() Function DOMCdataSection PHP DOMCdataSection __construct() Function DOMCha 2 min read PHP String Functions Complete Reference Strings are a collection of characters. For example, 'G' is the character and 'GeeksforGeeks' is the string. Installation: These functions are not required any installation. These are the part of PHP core. The complete list of PHP string functions are given below: Example: This program helps us to c 6 min read PHP intl Functions Complete Reference The Complete list of PHP intl Functions are listed below: Collator PHP collator_asort() FunctionPHP collator_compare() FunctionPHP Collator __construct() FunctionPHP Collator create() FunctionPHP collator_sort_with_sort_keys() FunctionPHP collator_sort() Function IntlCalendar PHP IntlCalendar add() 1 min read PHP Math Functions Complete Reference The predefined math functions in PHP are used to handle the mathematical operations within the integer and float types. These math functions are part of the PHP core. Installation: These functions have not required any installation. The complete list of PHP math functions are given below:Example: Pr 3 min read PHP Filesystem Functions Complete Reference The Filesystem function is used to access and manipulate filesystem. It is the part of PHP code so no need to install these functions. For accessing the files on the system, the file path will be used. On Unix system, forward slash (/) is used as a directory separator and on Windows platform, both f 4 min read Like