PHP
downloads | documentation | faq | getting help | mailing lists | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Tableaux et propriétés à la façon des tableaux de COM> <Erreur et gestion des erreurs
Last updated: Fri, 14 Nov 2008

view this page in

Exemples

Sommaire

For Each

Avec PHP 5, vous pouvez utiliser la structure de contrôle foreach de PHP pour passe 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 while() ... Next() en PHP 4

<?php
$domainObject 
= new COM("WinNT://Domain");
while (
$obj $domainObject->Next()) {
   echo 
$obj->Name "<br />";
}
?>

Exemple #3 foreach en PHP 5

<?php 
$domainObject 
= new COM("WinNT://Domain");
foreach (
$domainObject as $obj) {
   echo 
$obj->Name "<br />";
}
?>



add a note add a note User Contributed Notes
Exemples
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites