HomeLanguagesPHP | ArrayIterator getFlags() Function

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 ArrayIterator.

Below programs illustrate the ArrayIterator::getFlags() function in PHP:

Program 1:




<?php
   
// Declare an ArrayIterator
$arrItr = new ArrayIterator(
    array('G', 'e', 'e', 'k', 's', 'f', 'o', 'r')
);
  
// Get the flag
$flag = $arrItr->getFlags();
  
// Display the flag
var_dump($flag);
   
?>


Output:

int(0)

Program 2:




<?php
   
// Declare an ArrayIterator
$arrItr = new ArrayIterator(
    array("Geeks", "for", "Geeks")
);
   
// Append the element into array
$arrItr->append("Computer");
$arrItr->append("Science");
$arrItr->append("Portal");
  
// Get the flag
$flag = $arrItr->getFlags();
  
// Display the flag value
var_dump($flag);
  
?>


Output:

int(0)

Reference: https://www.php.net/manual/en/arrayiterator.getflags.php

RELATED ARTICLES

3 COMMENTS

Most Popular

Dominic
32686 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7052 POSTS0 COMMENTS
Nicole Veronica
12191 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12291 POSTS0 COMMENTS
Shaida Kate Naidoo
7178 POSTS0 COMMENTS
Ted Musemwa
7444 POSTS0 COMMENTS
Thapelo Manthata
7156 POSTS0 COMMENTS
Umr Jansen
7147 POSTS0 COMMENTS