Change language

PHP Ds / Stack toArray () Function

|
Syntax:
void public DsStack::toArray()
Parameters:this function takes no parameters.Return value:this function returns an array generated from the stack.The following programs illustrate the Ds / Stack function::toArray() :Program 1:  
// PHP illustration program
// toArray() function 
/ / Create a stack instance $stack = new DsStack();  
// Push items onto the stack $stack -> push ( "Welcome" ); $stack -> push ( "to" ); $stack -> push ( "GfG" );  
// Print the converted array print_r ( $stack -> toArray());  
// Print stack print_r ( $stack );  
?>
Output:
Array ([0] = > GfG [1] = > to [2] = > Welcome) DsStack Object ([0] = > GfG [1] = > to [2] = > Welcome)
Program 2:  
// PHP illustration program
// toArray() function 
// Create a stack instance $stack = new DsStack();  
// Put elements with mixed values ​​on the stack $stack -> push ( "Welcome" ); $stack -> push ( "to" ); $stack -> push ( "GfG" ); $stack -> push (10); $stack -> push (5.5);  
// Print the converted array print_r ( $stack -> toArray());  
// Print stack print_r ( $stack );  
?>
Output:
Array ([0] = > 5.5 [1] = > 10 [2] = > GfG [3] = > to [4] = > Welcome) DsStack Object ([0] = > 5.5 [1] = > 10 [2] = > GfG [3] = > to [4] = > Welcome)
Link : http://php.net/manual/en/ds-stack.toarray.php
SO 1 data error