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

search for in the

配列と配列形式の COM プロパティ> <エラーおよびエラー処理
Last updated: Fri, 03 Oct 2008

view this page in

目次

For Each

PHP 5 以降、標準的な COM/OLE IEnumVariant の内容について、 PHP の foreach 命令を使用した反復処理を行うことができます。分かりやすく言うと、 これは、VB/ASP のコードで For Each を使用できる場所には foreach を使用できるということを意味します。

例1 ASP における For Each

<%
Set domainObject = GetObject("WinNT://Domain")
For Each obj in domainObject
  Response.Write obj.Name & "<br />"
Next
%>

例2 PHP 4 における while() ... Next()

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

?>

例3 PHP 5 における foreach

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

?>



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

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