Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • PHP Tutorial
  • PHP Exercises
  • PHP Array
  • PHP String
  • PHP Calendar
  • PHP Filesystem
  • PHP Math
  • PHP Programs
  • PHP Array Programs
  • PHP String Programs
  • PHP Interview Questions
  • PHP GMP
  • PHP IntlChar
  • PHP Image Processing
  • PHP DsSet
  • PHP DsMap
  • PHP Formatter
  • Web Technology
Open In App
Next Article:
PHP SplObjectStorage key() Function
Next article icon

PHP SplObjectStorage next() Function

Last Updated : 11 May, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

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 SplObjectStorage::next() function in PHP: 

Program 1: 

php
<?php  // Create an empty SplObjectStorage $str = new SplObjectStorage();  $obj = new StdClass; $obj2 = new StdClass;  // Use attach() function to add object $str->attach($obj, "GFG"); $str->attach($obj2, "Geeks");  $str->rewind();  // Get the current data  var_dump($str->getInfo());  // Move on to next object $str->next();  // Print result of next entry var_dump($str->getInfo()); ?> 
Output:
string(3) "GFG" string(5) "Geeks"

Program 2: 

php
<?php  // Create an Empty SplObjectStorage $str = new SplObjectStorage();   $obj1 = new StdClass; $obj2 = new StdClass; $obj3 = new StdClass; $obj4 = new StdClass;   // Use attach() function to add object $str->attach($obj1, "GeeksforGeeks"); $str->attach($obj2, "GFG"); $str->attach($obj3); $str->attach($obj4, "DSA");   $str->rewind();   // Iterate and print data on each index while($str->valid()) {          // Get index      $index  = $str->key();     $object = $str->current();      $data   = $str->getInfo();       var_dump($index, $data);          // Moving each time next entry     $str->next(); } ?> 
Output:
int(0) string(12) "GeksforGeeks" int(1) string(3) "GFG" int(2) NULL int(3) string(3) "DSA"

Reference: https://www.php.net/manual/en/splobjectstorage.next.php


Next Article
PHP SplObjectStorage key() Function

R

R_Raj
Improve
Article Tags :
  • Web Technologies
  • PHP
  • PHP-function

Similar Reads

  • 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
  • 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 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 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 offsetUnset() Function
    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
    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 count() Function
    The SplObjectStorage::count() function is an inbuilt function in PHP which is used to count the number of objects in storage. Syntax: int SplObjectStorage::count() Parameters: This function does not contains any parameter. Return Value: This function returns number of objects in storage. Below progr
    1 min read
  • PHP SplObjectStorage valid() Function
    The SplObjectStorage::valid() function is an inbuilt function in PHP which is used to check the current storage entry is valid or not. Syntax: bool SplObjectStorage::valid() Parameters: This function does not accept any parameter. Return Value: This function returns true if the iterator entry is val
    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 attach() Function
    The SplObjectStorage::attach() function is an inbuilt function in PHP which is used to add objects into the SplObjectStorage. Syntax: void SplObjectStorage::attach($obj, $val) Parameters: This function accepts two parameters as mention above and described below. $obj: This is required parameter whic
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences