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 map returns the result of applying a callback to each valuephp sequence updates all values by applying a callback function to each valuephp vector updates all values by applying a callback function 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 fdf 函数 call a user defined function for each document valuephp imap 函数 read the list of mailboxes returning detailed information on each onephp 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 函数处理 函数 de register a function for execution on each tickphp yp/nis 函数 traverse the map and call a function on each entryphp gmagick randomly displaces each pixel in a blockphp 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 1
关注编程学问公众号