+

PHP Ds / Vector clear () function

Syntax:
void public DsVector::clear (void)
Parameters: this function takes no parameters.Return value:This function does not return any value.The following programs illustrate the Ds / Vector function: : clear()in PHP:Program 1:  
// Create a new vector $vector = new DsVector ([1, 2, 3, 4, 5]); echo ( " Original Vector " );  
// Display vector elements print_r ( $vector ); echo ( " Modified Vector " );  
// Use the clear() function for
// remove vector elements $vector -> clear();  
// Display vector elements print_r ( $vector );  
?>
Output:
Original Vector DsVector Object ([0] = > 1 [1] = > 2 [2] = > 3 [3] = > 4 [4] = > 5) Modified Vector DsVector Object ( )
Program 2:  
// Create a new vector $vector = new DsVector ([ "engineer" , "for" , "engineer" ]); echo ( " Original Vector " );  
// Display vector elements print_r ( $vector ); echo ( " Modified Vector " );  
// Use the clear() function for
// remove vector elements $vector -> clear();  
// Display vector elements print_r ( $vector );  
?>
Output:
Original Vector DsVector Object ([0] = > engineer [1] = > for [2] = > engineer) Modified Vector DsVector Object()
Link: http://php.net/manual/en/ds-vector.clear.php
Get Solution for free from DataCamp guru