I have the following code;

PHP Code:
<?php
    $objMetaFrameFarm 
= new COM("MetaFrameCOM.MetaFrameFarm");
    
$objMetaFrameFarm->Initialize(1);
    
    
$objTheSessions $objMetaFrameFarm->Sessions;
        
    print 
$objMetaFrameFarm->FarmName;
    
$objMetaFrameServers $objMetaFrameFarm->Servers;
    
    try
    {
        
        foreach(
$objMetaFrameServers as $objMetaFrameServer)
        {
            echo 
$objMetaFrameServer->ServerName;
        }
    }
    catch (
com_exception $x)
    {
        print 
$x "\n";
    }
    
?>
If I run it as is I get a http 500 error if I comment out the foreach the code seems to run fine. If I then add
PHP Code:
$count $objTheSessions->Count
inside the try it throws the following useful exception;

exception 'com_exception' with message 'Source: Unknown
Description: Unknown' in C:\Inetpub\wwwroot\Citrix_test_again.php:19 Stack trace: #0 C:\Inetpub\wwwroot\Citrix_test_again.php(19): unknown() #1 {main}

Count is a property of the Sessions object.
PHP Code:
print $objMetaFrameFarm->FarmName
works correctly and is output to the browser.

I was under the impression that foreach allows you to traverse a collection like for each in vb but this does not seem to be the case the sessions object does implement a _NewEnum property which returns an enumerator (ienumvariant) object for the collection I'm having some difficulty with the syntax though......

Does anyone have any suggestions? Thanks.