PHP | Ds\Deque toArray() Function Last Updated : 14 Aug, 2019 Comments Improve Suggest changes Like Article Like Report 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 Value: This function returns the array which contains all the elements of the Deque in the same order. Below programs illustrate the Ds\Deque::toArray() function in PHP: Program 1: PHP <?php // Declare a deque $deck = new \Ds\Deque([5, 6, 3, 2, 7, 1]); echo("Elements of Deque\n"); // Display the Deque elements print_r($deck); echo("Array elements\n"); // Use toArray() function to // convert Deque into array print_r($deck->toArray()); ?> Output: Elements of Deque Ds\Deque Object ( [0] => 5 [1] => 6 [2] => 3 [3] => 2 [4] => 7 [5] => 1 ) Array elements Array ( [0] => 5 [1] => 6 [2] => 3 [3] => 2 [4] => 7 [5] => 1 ) Program 2: PHP <?php // Declare a deque $deck = new \Ds\Deque(["geeks", "for", "geeks", "data structures"]); echo("Elements of Deque\n"); // Display the Deque elements var_dump($deck); echo("Array elements\n"); // Use toArray() function to // convert Deque into array var_dump($deck->toArray()); ?> Output: Elements of Deque object(Ds\Deque)#1 (4) { [0]=> string(5) "geeks" [1]=> string(3) "for" [2]=> string(5) "geeks" [3]=> string(15) "data structures" } Array elements array(4) { [0]=> string(5) "geeks" [1]=> string(3) "for" [2]=> string(5) "geeks" [3]=> string(15) "data structures" } Reference: http://php.net/manual/en/ds-deque.toarray.php Comment More infoAdvertise with us Next Article PHP DsQueue toArray() Function B barykrg Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_deque Similar Reads 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 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 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 | 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 | DsVector toArray() Function The Ds\Vector::toArray() function is an inbuilt function in PHP which is used to convert the vector into an array. All the elements of the vector are copied to the array.Syntax: array public Ds\Vector::toArray( void ) Parameters: This function does not accepts any parameters.Return Value: This funct 2 min read PHP | DsDeque sort() Function The Ds\Deque::sort() function is an inbuilt function in PHP which is used to sort the Deque in place by arranging the elements in increasing order. Syntax: public Ds\Deque::sort( $comparator ) : void Parameters::This function accepts single parameter $comparator which holds the function to decides h 2 min read PHP DsPriorityQueue toArray() Function The Ds\PriorityQueue::toArray() Function in PHP is used to convert a PriorityQueue into an associative array in PHP. The values of the PriorityQueue are assigned to the array in order of decreasing priority. Syntax: array public Ds\PriorityQueue::toArray ( void ) Parameters: This function does not a 1 min read PHP | DsDeque set() Function The Ds\Deque::set() function is an inbuilt function in PHP which is used to set the value at the given index in the Deque. Syntax: public Ds\Deque::set( $index, $value ) : void Parameters: This function accept two parameters as mentioned above and described below: index: This parameter holds the ind 2 min read Like