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 sequence updates all values by applying a callback function 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 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 mysqlnd qc 函数 returns a normalized query trace log for each query inspected by the query cachephp mysqlnd qc 函数 returns a backtrace for each query inspected by the query cachephp 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 evaluate expression for each pixel in the imagephp imagick randomly displaces each pixel in a blockphp rrdcreator adds rra archive of data values for each data sourcephp solrquery returns the number of similar documents to return for each resultphp solrquery returns the maximum number of tokens to parse in each document field that is not stored with termvector supportphp solrquery sets the number of rows to display in each group expand.rows . server default 5php 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 query
关注编程学问公众号