PHP SplObjectStorage offsetUnset() Function Last Updated : 23 Jun, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The SplObjectStorage::offsetUnset() function is an inbuilt function in PHP that is used to set the object from the storage. Syntax: void SplObjectStorage::offsetUnset( $object ) Parameters: This function accepts a single parameter $object which specifies the to be unset. Return Value: This function does not return any value. The below programs illustrate the SplObjectStorage::offsetUnset() function in PHP. Program 1: php <?php // Create an empty SplObjectStorage $str = new SplObjectStorage; $obj = new StdClass; // Set offset $obj to $str $str->attach($obj, "GeeksforGeeks"); // Print Result before var_dump(count($str)); // Unset object from storage $str->offsetUnset($obj); // Print Result after var_dump(count($str)); ?> Output:int(1) int(0) Program 2: php <?php // Create an Empty SplObjectStorage $str = new SplObjectStorage(); $obj1 = new StdClass; $obj2 = new StdClass; $obj3 = new StdClass; $obj4 = new StdClass; $str->attach($obj1, "GeeksforGeeks"); $str->attach($obj2, "GFG"); $str->attach($obj3); $str->attach($obj4, "DSA"); // Print Result before var_dump(count($str)); // Unset object from storage $str->offsetUnset($obj1); $str->offsetUnset($obj2); $str->offsetUnset($obj3); $str->offsetUnset($obj4); // Print Result after var_dump(count($str)); ?> Output:int(4) int(0) Reference: https://www.php.net/manual/en/splobjectstorage.offsetunset.php Comment More infoAdvertise with us Next Article PHP SplObjectStorage getinfo() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP SplObjectStorage offsetSet() Function The SplObjectStorage::offsetSet() function is an inbuilt function in PHP which is used to set the object of storage. Syntax: void SplObjectStorage::offsetSet($obj, $val) Parameters: This function accept two parameters as mention above and described below: $obj: It specifies the object to be attach.$ 1 min read PHP SplObjectStorage offsetGet() Function The SplObjectStorage::offsetGet() function is an inbuilt function in PHP that is used to get the data associated with the object. Syntax: object SplObjectStorage::offsetGet($obj) Parameters: This function accepts a single parameter $obj which specifies the object to be fetched. Return Value: This fu 1 min read PHP SplObjectStorage offsetExists() Function The SplObjectStorage::offsetExists() function is an inbuilt function in PHP which is used to check the object exist in storage or not. Syntax: bool SplObjectStorage::offsetExists($object) Parameters: This function accepts a single parameter $object which specifies the object to be checked.Return Val 1 min read PHP SplObjectStorage next() Function The SplObjectStorage::next() function is an inbuilt function in PHP which is used to move to next entry of storage. Syntax: void SplObjectStorage::next() Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below programs illustrate the SplO 1 min read PHP SplObjectStorage getinfo() Function The SplObjectStorage::getinfo() function is an inbuilt function in PHP that is used to get the data associated with the object by the current iterator position. Syntax: mixed SplObjectStorage::getinfo() Parameters: This function does not accept any parameter. Return Value: This function returns the 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