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.

Example #1 For Each in ASP

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

Example #2 foreach in PHP

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

?>

相关文章
php 范例 for eachphp deque updates all values by applying a callback function to each valuephp deque returns the result of applying a callback to each valuephp map updates all values by applying a callback function to each valuephp sequence returns the result of applying a callback to each valuephp vector updates all values by applying a callback function to each valuephp vector returns the result of applying a callback to each valuephp eventbufferevent creates two buffer events connected to each otherphp cubrid mysql 兼容性函数 return an array with the lengths of the values of each field from the current rowphp frontbase 函数 get the length of each output in a resultphp mailparse 函数 scans the data from fp and extract each embedded uuencoded filephp odbc 函数 lists tables and the privileges associated with each tablephp swoole 函数 get the ipv4 ip addresses of each nic on the machinephp haruimage get the number of bits used to describe each color component of the imagephp imagick selects a threshold for each pixel based on a range of intensityphp imagick randomly displaces each pixel in a blockphp solrquery returns the maximum number of tokens to parse in each document field that is not stored with termvector supportphp solrquery specifies the number of results to return for each group. the server default value is 1php solrquery if true facet counts are based on the most relevant document of each group matching the queryphp solrquery set the number of similar documents to return for each result
关注编程学问公众号