Open In App

PHP | Ds\Pair clear() Function

Improve
Improve
Like Article
Like
Save
Share
Report

The Ds\Pair::clear() function is an inbuilt function in PHP which is used to remove all values from the pair.

Syntax:

void Ds\Pair::clear( void )

Parameters: This function does not accept any parameters.

Return Value: This function does not return any value.

Below programs illustrate the Ds\Pair::clear() function in PHP:

Program:




<?php 
  
// Create new pair 
$pair = new \Ds\Pair("G", "GeeksforGeeks"); 
  
echo ("Original pair elements:\n"); 
  
// Display the pair elements 
print_r($pair); 
  
echo("Modified pair\n"); 
  
// Use clear() function to 
// remove pair elements 
$pair->clear(); 
  
// Display pair elements 
print_r($pair); 
  
?> 


Output:

Original pair elements:
Ds\Pair Object
(
    [key] => G
    [value] => GeeksforGeeks
)
Modified pair
Ds\Pair Object
(
)

Reference: https://www.php.net/manual/en/ds-pair.clear.php


Last Updated : 30 Jul, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads