Change language

PHP SplObjectStorage setInfo () function

Syntax:
void SplObjectStorage::setInfo ($val)
Parameters: This function takes one parameter, $val,which specifies the data to be associated with the current iterator record in the store.Return value:this function is not returns no value.The following programs illustrate the function SplObjectStorage::setInfo()in PHP:Program 1: $str = new SplObjectStorage(); $obj1 = new StdClass; $str -> attach ( $obj1 , " GeeksforGeeks " ); $str -> rewind ();  
// Set new information for $obj1 in the $str repository $str -> setInfo ( "new_GeeksforGeeks " );  
// Print the result var_dump ( $str [ $obj1 ]); ?>
Exit:
string (17 ) "new_GeeksforGeeks"
Program 2: $obj1 = new StdClass; $obj2 = new StdClass; $obj3 = new StdClass; $gfg = new SplObjectStorage(); $gfg [ $obj1 ] = "GFG" ; $gfg [ $obj2 ] = "GeeksClasses" ; $gfg [ $obj3 ] = "SUDO" ;  
// Using the rewind function $gfg -> rewind (); while ( $gfg -> valid()) { $gfg -> setInfo ( " Modified_GFG_DATA " ); var_dump ( $gfg -> getInfo()); // Move to next element $gfg -> next(); }
?>
Exit:
string (17 ) "Modified_GFG_DATA" string (17) "Modified_GFG_DATA" string (17) "Modified_GFG_DATA"
Link: https://www.php.net/manual/en/splobjectstorage.setinfo.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method