PHP - Pair Class Functions
In PHP, The Pair class in the DS extension is used to create and manage a pair of values. It acts as a container for two related values. This can be useful when you want to group two values, such as a key-value pair or a coordinate.
Note: The clear() and isEmpty() functions are not available in the latest version of PHP, so ensure you have the relevant version of PHP that supports these functions while working with these functions.
List of Functions
Below is the list of functions provided by the Pair class −
| Sr.No | Functions & Description |
|---|---|
| 1 |
This function can remove all values from the pair. |
| 2 | Ds\Pair::__construct() Function This function can create a new instance. |
| 3 |
This function can return a shallow copy of the pair. |
| 4 |
This function can return whether the pair is empty. |
| 5 | Ds\Pair::jsonSerialize() Function This function can return a representation that can be converted to JSON. |
| 6 |
This function can convert a pair to an array. |