How do you read from a multidimensional variant array returned from a COM object in PHP? -


i'm working com object returns multidimensional variant array (vt_array), , i'm trying read values array.

when use print_r($mdarray) displays variant object. (variant_get_type($mdarray) returns 8204.)

i tried using foreach ($mdarray $onearray) message:

warning: loader::getfields() [loader.getfields]: can handle single dimension variant arrays (this array has 2) in c:\inetpub\wwwroot\root\script\fileloader.php on line 135 fatal error: uncaught exception 'exception' message 'object of type variant did not create iterator' in c:\inetpub\wwwroot\root\script\fileloader.php:135 stack trace: #0 c:\inetpub\wwwroot\root\script\fileloader.php(135): loader::getfields() #1 c:\inetpub\wwwroot\root\testloader.php(21): loader->getfields() #2 {main} thrown in c:\inetpub\wwwroot\root\script\fileloader.php on line 135

(the foreach loop on line 135)

the information can array using count($mdarray) returns 8.

if here has experience reading multidimensional variant arrays please tell me how can done.

try extract array values through "vbscript". yes, read right...

<?php  $com = new com("msscriptcontrol.scriptcontrol"); $com->language = 'vbscript'; $com->allowui = false; $com->addcode('     function getarrayval(arr, indexx, indexy)         getarrayval = arr(indexx, indexy)     end function ');  $y1 = 0; $y2 = 1; ($x=0; $x < count($mdarray); $x++) {     echo $com->run('getarrayval', $mdarray, $x, $y1) . ": ";     echo $com->run('getarrayval', $mdarray, $x, $y2) . "\n";     }  ?> 

tested on vbscript-created array, otherwise gave me exact same issues , errors when trying coerce behave php array. above method spawned unholy union of php , vbscript should extract values piece piece fine.

to explain $y1 = 0; $y2 = 1;, keep in mind parameters of vbscript function byref, can't pass in except variable.

edit: added $com->allowui = false shut off on-screen popups. otherwise freeze request if msgbox() somehow got called vbscript , no 1 @ server terminal click 'ok'.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -