Wednesday, July 3, 2024
HomeLanguagesPhpPHP | DsPair clear() Function

PHP | Ds\Pair clear() Function

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", "neveropen"); 
  
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] => neveropen
)
Modified pair
Ds\Pair Object
(
)

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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Nicole Veronica Rubhabha
Nicole Veronica Rubhabha
A highly competent and organized individual DotNet developer with a track record of architecting and developing web client-server applications. Recognized as a personable, dedicated performer who demonstrates innovation, communication, and teamwork to ensure quality and timely project completion. Expertise in C#, ASP.Net, MVC, LINQ, EF 6, Web Services, SQL Server, MySql, Web development,
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments