PHP Portal » PHP Handbuch » For Each

Werbung

For Each


Starting with PHP 5, you may use PHP's own foreach statement to iterate over the contents of a standard COM/OLE IEnumVariant. In layman's terms, this means that you can use foreach in places where you would have used For Each in VB/ASP code.

Beispiel #2 while() ... Next() in PHP 4

PHP Code
1
2
3
4
$domainObject = new COM("WinNT://Domain"); while ($obj = $domainObject->Next()) { echo $obj->Name . "<br />"; }

PHP Code
1
2
3
4
$domainObject = new COM("WinNT://Domain"); foreach ($domainObject as $obj) { echo $obj->Name . "<br />"; }