From: Peter N. <pn...@kr...> - 2005-01-31 21:57:30
|
Hi, Jost Boekemeier schrieb: > Hi, > > >>public NameValue[] process_context >>$nameValues = $activity->process_context(); >>So far I couldn't figure out a way how to iterate through all the >>elements of the returned array in PHP. > > > $Array = new java_class("java.lang.reflect.Array"); > for($i=0; $i<$Array->getLength($nameValues); $i++) > echo $nameValues[i] . "\n"; > > should work if you have PHP5 (please see > tests.php5/arrayInterface.php). PHP5 is quite OK. Works perfect this way, Thx! (I looked at all the tests and examples already but didn't manage to adjust it to my problem correctly) > In PHP4 the bridge uses the same method > as the ext/java: it copies all elements from the java array into a PHP > hashtable $nameValues. I don't know at the moment how it is possible to > ask a PHP hash table for its length. Sorry, no help from me. :-< [...] >>'foreach ($nameValues as $value) { echo "soemthing" }' work. > > > This should work in both PHP4 and PHP5, please see > tests.php5/iteratorInterface.php. The example uses a Map, but > getPhpMap() works for Arrays, Maps and Collections. > > Can you please set the log level to debug and send the result? I am > looking for the output of: logDebug("returning map for "+ > value.getClass()); OK, here you go, since the log-file is 70k I just put it online [1] instead of posting it to the list. What I am doing is only proof-of-concept for an exam, no production-code. performancewise(and stability) I should probably rather do a lot of the stuff in a native java-library instead. It involves heavy usage of CORBA, so that might be causing the problem? Although, it pretty much looks like it was really possible to use a java CORBA-library within PHP. >>Do I need to modify the native Java-Class so it provides another >>java-interface(collection,ArrayList)? > > > Not necessary. I think that for some reason the value is neither an > Array, nor a Map or Collection. We'll see. hopefully it is of some help... [1] http://www.niekom.de/pub/php-java-bridge.log Big thx, Peter |