array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'com.examples.foreach.php', 1 => 'For Each', ), 'up' => array ( 0 => 'com.examples.php', 1 => 'Exemples', ), 'prev' => array ( 0 => 'com.examples.php', 1 => 'Exemples', ), 'next' => array ( 0 => 'com.examples.arrays.php', 1 => 'Tableaux et propriétés à la façon des tableaux de COM', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/com/examples.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
Vous pouvez utiliser la structure de contrôle foreach
de PHP pour passer en boucle à travers le contenu d'un IEnumVariant COM/OLE standard.
Cela signifie que vous pouvez utiliser foreach aux endroits où
vous auriez pu utiliser For Each
dans du code VB/ASP.
Exemple #1 For Each en ASP
<% Set domainObject = GetObject("WinNT://Domain") For Each obj in domainObject Response.Write obj.Name & "<br />" Next %>
Exemple #2 Foreach en PHP
<?php
$domainObject = new COM("WinNT://Domain");
foreach ($domainObject as $obj) {
echo $obj->Name . "<br />";
}
?>