Change language

PHP ArrayIterator offsetUnset () function

Syntax:
void ArrayIterator::offsetUnset (mixed $index)
Parameters:This function takes one parameter, $index,which contains the index to reset the offset.Return value:this function returns no value.The following programs illustrate the ArrayIterator::offsetUnset() function in PHP:Program 1:

 
// Declare ArrayIterator $arrItr = new ArrayIterator ( array ( " a " = > 4, "b" = > 2, "g" = > 8, "d" = > 6, "e" = > 1, "f" = > 9 ) );  
// Display the offset value var_dump ( $arrItr -> offsetGet ( "a" ));  
// Reset the offset value var_dump ( $arrItr -> offsetUnset ( "a" ));  
// Display the offset value var_dump ( $arrItr -> offsetGet ( "g" ));  
// Reset the offset value var_dump ( $arrItr -> offsetUnset ( "g" ));  
// Display the offset value var_dump ( $arrItr -> offsetGet ( "f" ));  
// Reset the offset value var_dump ( $arrItr -> offsetUnset ( "f" ));  
?>
Exit:
int (4 ) NULL int (8) NULL int (9) NULL
Program 2:  
// Declare ArrayIterator $arrItr = new ArrayIterator ( array ( "for" , "Geeks" , "Science" , "Geeks" , "Portal" , "Computer" ) );  
// Print the value at index 1 echo $arrItr -> offsetGet (1). "" ;  
// Reset the offset value var_dump ( $arrItr -> offsetUnset (1));  
// Display the value at index 0 echo $arrItr -> offsetGet (0). "" ;  
// Reset the offset value var_dump ( $arrItr -> offsetUnset (0));  
// Display the value at index 3 echo $arrItr -> offsetGet (3). "" ;  
// Reset the offset value var_dump ( $arrItr -> offsetUnset (3));  
?>
Exit:
Geeks NULL for NULL Geeks NULL
Link: https://www.php .net / manual / en / arrayiterator.offsetunset.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