iterator_count

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

iterator_countCount the elements in an iterator

Beschreibung

iterator_count(Traversable $iterator): int

Count the elements in an iterator. iterator_count() is not guaranteed to retain the current position of the iterator.

Parameter-Liste

iterator

The iterator being counted.

Rückgabewerte

The number of elements in iterator.

Beispiele

Beispiel #1 iterator_count() example

<?php
$iterator 
= new ArrayIterator(array('recipe'=>'pancakes''egg''milk''flour'));
var_dump(iterator_count($iterator));
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

int(4)

Beispiel #2 iterator_count() modifies position

<?php
$iterator 
= new ArrayIterator(['one''two''three']);
var_dump($iterator->current());
var_dump(iterator_count($iterator));
var_dump($iterator->current());
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

string(3) "one"
int(3)
NULL

Beispiel #3 iterator_count() in foreach loops

<?php
$iterator 
= new ArrayIterator(['one''two''three']);
foreach (
$iterator as $key => $value) {
    echo 
"$key$value ("iterator_count($iterator), ")\n";
}
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

0: one (3)

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Sell SSN | NIN | SIN | EIN | W-2 FORMS | REAL DL | HIGH CS FULLZ | FULLZ INFO SSN DOB

TELE: @thebunny92 | Sell SSN | NIN | SIN | EIN | W-2 FORMS | REAL DL | HIGH CS FULLZ | FULLZ INFO SSN DOB....US UK EU.... ------DETAIL for contac ...

Geschrieben von vinken1000 am 13.06.2026 12:22:44
Forum: PHP Developer Forum
Sell SSN | NIN | SIN | EIN | W-2 FORMS | REAL DL | HIGH CS FULLZ | FULLZ INFO SSN DOB

TELE: @thebunny92 | Sell SSN | NIN | SIN | EIN | W-2 FORMS | REAL DL | HIGH CS FULLZ | FULLZ INFO SSN DOB....US UK EU.... ------DETAIL for contac ...

Geschrieben von vinken1000 am 13.06.2026 12:02:09
Forum: PHP Developer Forum
@thebunny92 | Sell SSN | NIN | SIN | EIN | W-2 FORMS | REAL DL | HIGH CS FULLZ | FULL

SSN DOB | FULL INFO ON SSNDOB | REAL DL Fullz with Issue & Exp Dates | NIN DOB ADDRESS | BUSINESS EIN COMPANY Passport Photos with Selfie | High C ...

Geschrieben von vinken1000 am 13.06.2026 11:59:39
Forum: Linux und Unix
@thebunny92 | Sell SSN | NIN | SIN | EIN | W-2 FORMS | REAL DL | HIGH CS FULLZ | FULL

Telegram: @thebunny92 ( The Bunny ) Link : https://t.me/thebunny92​

Geschrieben von vinken1000 am 13.06.2026 11:58:41
Forum: Linux und Unix