PHP SplObjectStorage removeAll() Function Last Updated : 23 Jun, 2023 Comments Improve Suggest changes Like Article Like Report The SplObjectStorage::removeAll() function is an inbuilt function in PHP which is used to remove all objects contained in another storage from the current storage. Syntax: void SplObjectStorage::removeAll( $obj ) Parameters: This function accepts a single parameter $obj which specify the storage to be removed from the current storage. Return Value: This function does not return any value. Below programs illustrate the SplObjectStorage::removeAll() function in PHP: Program 1: php <?php $obj1 = new StdClass; $obj2 = new StdClass; $gfg1 = new SplObjectStorage(); $gfg1[$obj1] = "Geeks"; $gfg2 = new SplObjectStorage(); $gfg2[$obj1] = "GFG"; $gfg2[$obj2] = "GeeksClasses"; // Count and print all existing objects var_dump(count($gfg2)); // Remove all objects of $gfg1 from $gfg2 $gfg2->removeAll($gfg1); // Print result after removeAll var_dump(count($gfg2)); ?> Output: int(2) int(1) Program 2: php <?php $obj1 = new StdClass; $obj2 = new StdClass; $gfg1 = new SplObjectStorage(); $gfg1[$obj1] = "Geeks"; $gfg2 = new SplObjectStorage(); $gfg2[$obj1] = "GFG"; $gfg2[$obj2] = "GeeksClasses"; // Count and print all existing objects var_dump(count($gfg2)); // Remove all objects of $gfg1 from $gfg2 $gfg2->removeAll($gfg1); // Print result after removeAll var_dump(count($gfg2)); // Remove all objects itself $gfg2 $gfg2->removeAll($gfg2); // Print result after removeAll var_dump(count($gfg2)); ?> Output: int(2) int(1) int(0) Reference: https://www.php.net/manual/en/splobjectstorage.removeall.php Comment More infoAdvertise with us Next Article PHP SplObjectStorage removeAll() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP SplObjectStorage removeAllExcept() Function The SplObjectStorage::removeAllExcept() function is an inbuilt function in PHP which is used to remove all objects from storage except for those contains by another storage. Syntax: int SplObjectStorage::removeAllExcept() Parameters: This function accepts a single parameter $obj which specify object 1 min read PHP SplObjectStorage rewind() Function The SplObjectStorage::rewind() function is an inbuilt function in PHP which is used to rewind the iterator to the first storage element. Syntax: void SplObjectStorage::rewind() Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below progr 1 min read PHP SplObjectStorage serialize() Function The SplObjectStorage::serialize() function is an inbuilt function in PHP which is used to serialize the result of the storage. Syntax: string SplObjectStorage::serialize() Parameters: This function does not accept any parameter. Return Value: This function returns a string which is the representatio 1 min read PHP SplObjectStorage setInfo() Function The SplObjectStorage::setInfo() function is an inbuilt function in PHP which is used to set the data associated with the current iterator entry. Syntax: void SplObjectStorage::setInfo( $val ) Parameters: This function accepts a single parameter $val which specifies the data to be associate to the cu 1 min read PHP SplObjectStorage key() Function The SplObjectStorage::key() function is an inbuilt function in PHP which is used to get the index of the currently pointing iterator. Syntax: int SplObjectStorage::key() Parameters: This function does not accept any parameter. Return Value: This function returns the index at which the iterator curre 1 min read Like