PHP | ArrayIterator offsetExists() Function Last Updated : 21 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The ArrayIterator::offsetExists() function is an inbuilt function in PHP which is used to check the existence of offset at the given index. Syntax: bool ArrayIterator::offsetExists( mixed $index ) Parameters: This function accepts single parameter $index which holds the index value to check the existence of offset. Return Value: This function returns TRUE if the offset exists, otherwise returns FALSE. Below programs illustrate the ArrayIterator::offsetExists() function in PHP: Program 1: php <?php // Declare an 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")); // Check the existence of offset var_dump($arrItr->offsetExists("a")); // Unset the offset value var_dump($arrItr->offsetUnset("a")); // Check the existence of offset var_dump($arrItr->offsetExists("a")); ?> Output: int(4) bool(true) NULL bool(false) Program 2: php <?php // Declare an ArrayIterator $arrItr = new ArrayIterator( array( "for", "Geeks", "Science", "Geeks", "Portal", "Computer" ) ); // Print the value at index 1 echo $arrItr->offsetGet(1) . "\n"; // Check the existence of offset var_dump($arrItr->offsetExists(1)); // Unset the offset value var_dump($arrItr->offsetUnset(1)); // Check the existence of offset var_dump($arrItr->offsetExists(1)); // Print the value at index 0 echo $arrItr->offsetGet(0) . "\n"; // Check the existence of offset var_dump($arrItr->offsetExists(0)); // Unset the offset value var_dump($arrItr->offsetUnset(0)); // Check the existence of offset var_dump($arrItr->offsetExists(0)); ?> Output: Geeks bool(true) NULL bool(false) for bool(true) NULL bool(false) Reference: https://www.php.net/manual/en/arrayiterator.offsetexists.php Comment More infoAdvertise with us Next Article PHP | ArrayIterator offsetExists() Function jit_t Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Iterators PHP-ArrayIterator +1 More Similar Reads PHP | ArrayIterator offsetGet() Function The ArrayIterator::offsetGet() function is an inbuilt function in PHP which is used to get the value of an offset. Syntax: mixed ArrayIterator::offsetGet( mixed $index ) Parameters: This function accepts single parameter $index which holds the offset to get the value from. Return Value: This functio 1 min read PHP | ArrayIterator offsetSet() Function The ArrayIterator::offsetSet() function is an inbuilt function in PHP which is used to set the value for an offset. Syntax: void ArrayIterator::offsetSet( mixed $index, mixed $newval ) Parameters: This function accepts two parameters as mentioned above and described below: $index: This parameter hol 2 min read PHP | ArrayIterator offsetUnset() Function The ArrayIterator::offsetUnset() function is an inbuilt function in PHP which is used to unset the value for an offset. Syntax: void ArrayIterator::offsetUnset( mixed $index ) Parameters: This function accepts single parameter $index which holds the index to unset the offset. Return Value: This func 2 min read PHP | ArrayIterator next() Function The ArrayIterator::next() function is an inbuilt function in PHP which is used to move the iterator to the next entry. Syntax: void ArrayIterator::next( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate t 1 min read ArrayObject offsetExists() Function in PHP The offsetExists() function of the ArrayObject class in PHP is used to whether a given offset or index is present in the ArrayObject or not. If it is present then the function returns a boolean True value otherwise it returns False. Syntax: bool offsetExists($index) Parameters: This function accepts 2 min read PHP | ArrayIterator natsort() Function The ArrayIterator::natsort() function is an inbuilt function in PHP which is used to sort an array naturally. Syntax: void ArrayIterator::natsort( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the Arr 1 min read PHP | ArrayIterator ksort() Function The ArrayIterator::ksort() function is an inbuilt function in PHP which is used to sort the array element by key. Syntax: void ArrayIterator::ksort( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. Below programs illustrate the A 2 min read PHP | ArrayIterator getFlags() Function The ArrayIterator::getFlags() function is an inbuilt function in PHP which is used to get the behavior of flags of array iterator. Syntax: int ArrayIterator::getFlags( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the behavior flags of the Array 1 min read PHP | ArrayIterator key() Function The ArrayIterator::key() function is an inbuilt function in PHP which returns the current key of the array element. Syntax: mixed ArrayIterator::key( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the current array key. Below programs illustrate 1 min read ArrayObject offsetGet() Function in PHP The offsetGet() function of the ArrayObject class in PHP is used to get the value present at a specific index at the ArrayObject. Syntax: mixed offsetGet($index) Parameters: This function accepts a single parameter $index for which corresponding value will be returned. Return Value: This function re 1 min read Like