PHP Ds\Set Functions Complete Reference Last Updated : 25 Jan, 2023 Summarize Comments Improve Suggest changes Share 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 S Sabya_Samadder Follow Improve Article Tags : Web Technologies PHP PHP-ds_set Similar Reads JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read React Tutorial React is a powerful JavaScript library for building fast, scalable front-end applications. Created by Facebook, it's known for its component-based structure, single-page applications (SPAs), and virtual DOM,enabling efficient UI updates and a seamless user experience.Note: The latest stable version 7 min read JavaScript Interview Questions and Answers JavaScript is the most used programming language for developing websites, web servers, mobile applications, and many other platforms. In Both Front-end and Back-end Interviews, JavaScript was asked, and its difficulty depends upon the on your profile and company. Here, we compiled 70+ JS Interview q 15+ min read Domain Name System (DNS) DNS is a hierarchical and distributed naming system that translates domain names into IP addresses. When you type a domain name like www.geeksforgeeks.org into your browser, DNS ensures that the request reaches the correct server by resolving the domain to its corresponding IP address.Without DNS, w 8 min read HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML 14 min read NodeJS Interview Questions and Answers NodeJS is one of the most popular runtime environments, known for its efficiency, scalability, and ability to handle asynchronous operations. It is built on Chromeâs V8 JavaScript engine for executing JavaScript code outside of a browser. It is extensively used by top companies such as LinkedIn, Net 15+ min read Web Development Technologies Web development refers to building, creating, and maintaining websites. It includes aspects such as web design, web publishing, web programming, and database management. It is the creation of an application that works over the internet, i.e., websites.To better understand the foundation of web devel 7 min read CSS Tutorial CSS stands for Cascading Style Sheets. It is a stylesheet language used to style and enhance website presentation. CSS is one of the three main components of a webpage, along with HTML and JavaScript.HTML adds Structure to a web page.JavaScript adds logic to it and CSS makes it visually appealing or 7 min read Like