略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: For Each

2025-02-27

For Each

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.

示例 #1 For Each in ASP

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

示例 #2 foreach in PHP

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

用户贡献的备注

此页面尚无用户贡献的备注。

官方地址:https://www.php.net/manual/en/com.examples.foreach.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3