PHP | Ds\Pair toArray() Function Last Updated : 30 Jul, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Pair::toArray() function is an inbuilt function in PHP which is used to convert the Pair element into an associative array. This function does not modify the actual Pair. This method returns an array whose values without changing the order of elements. Syntax: array Ds\Pair::toArray( void ) Parameters: This function does not accept any parameter. Return Value: This function returns an associative array generated by converting the Pair element. Below programs illustrate the Ds\Pair::toArray() function in PHP: Program 1: php <?php // Declare a Pair $pair = new \Ds\Pair("a", "GeeksforGeeks"); // Corresponding array is echo "Array is:\n"; print_r($pair->toArray()); ?> Output: Array is: Array ( [key] => a [value] => GeeksforGeeks ) Program 2: php <?php // Declare a Pair $pair = new \Ds\Pair([1, 2], ["GeeksforGeeks", "Welcome"]); // Corresponding array is echo "Array is:\n"; var_dump($pair->toArray()); ?> Output: Array is: array(2) { ["key"]=> array(2) { [0]=> int(1) [1]=> int(2) } ["value"]=> array(2) { [0]=> string(13) "GeeksforGeeks" [1]=> string(7) "Welcome" } } Reference: https://www.php.net/manual/en/ds-pair.toarray.php Comment More infoAdvertise with us Next Article PHP | DsDeque toArray() Function J jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_pair Similar Reads PHP DsMap toArray() Function The Ds\Map::toArray() function in PHP is used to get an array generated by converting the Map instance into an Array. The resulting array is an associative array with elements as in same order as that of the specified Map instance. Syntax: array public Ds\Map::toArray ( void ) Parameter: This functi 1 min read PHP DsSet toArray() Function The Ds\Set::toArray() function of Ds\Set class in PHP is an inbuilt function which is used to convert the Set into an associative array. This does not modify the actual Set. This method returns an array with values of the Set without changing the order of elements. Syntax: array public Ds\Set::toArr 1 min read PHP | DsPair toArray() Function The Ds\Pair::toArray() function is an inbuilt function in PHP which is used to convert the Pair element into an associative array. This function does not modify the actual Pair. This method returns an array whose values without changing the order of elements. Syntax: array Ds\Pair::toArray( void ) P 1 min read PHP | DsDeque toArray() Function The Ds\Deque::toArray() function is an inbuilt function in PHP which is used to convert a Deque into an array. The elements of the array will be in the same order as they are in Deque. Syntax: public Ds\Deque::toArray( void ) : array Parameters: This function does not accept any parameter. Return Va 2 min read PHP | DsStack toArray() Function The Ds\Stack::toArray() function of PHP is used to convert the stack to an array and returns the converted array. This function does not modify the actual Stack. Syntax: void public Ds\Stack::toArray () Parameters: This function does not accept any parameters. Return Value: This function returns the 2 min read PHP DsQueue toArray() Function The Ds\Queue::toArray() Function in PHP is used to convert a Queue into an associative array in PHP. The values of the Queue are assigned to the array in the same order as they are present in the Queue. Syntax: array public Ds\Queue::toArray ( void ) Parameters: This function does not accepts any pa 1 min read Like