Hi Jost,
sorry an email done again of me, but either I make something wrong or
perhaps I have found a little bug. However I hope you can help me ;-)
If java returns a multidimensional array, the bridge takes this as a nested
one-dimensional array.
A small example:
public class javatest {
public javatest() {
}
public static Object[][] test3(String testvar1, String testvar2, String
testvar3, String testvar4) {
Object[][] testobj = null;
testobj = new Object[2][2];
testobj[0][0] = testvar1;
testobj[0][1] = testvar2;
testobj[1][0] = testvar3;
testobj[1][1] = testvar4;
return testobj;
}
}
<?php
$testvar = new Java('javatest');
$testobj3 = $testvar->test3("Field 1,1","Field 1,2","Field 2,1","Field
2,2");
print "testobj3: ";
print_r($testobj3);
print "<br>";
for ($i = 0; $i < 2; $i++) {
for ($j = 0; $j < 2; $j++) {
print "$i,$j: " . $testobj3[$i][$j] .' <br>';
}
}
print "0,2: " . $testobj3[0][2] .' <br>';
$phptestobj = array(array("Field 1,1","Field 1,2"),
array("Field 2,1","Field 2,2"));
print "phptestobj: ";
print_r($phptestobj);
print "<br>";
for ($i = 0; $i < 2; $i++) {
for ($j = 0; $j < 2; $j++) {
print "$i,$j: " . $phptestobj[$i][$j] .' <br>';
}
}
?>
Output:
testobj3: Array ( [0] => Array ( [0] => Field 1,1 [1] => Field 1,2 [2] =>
Array ( [0] => Field 2,1 [1] => Field 2,2 ) ) )
0,0: Field 1,1
0,1: Field 1,2
1,0:
1,1:
0,2: Array
phptestobj: Array ( [0] => Array ( [0] => Field 1,1 [1] => Field 1,2 ) [1]
=> Array ( [0] => Field 2,1 [1] => Field 2,2 ) )
0,0: Field 1,1
0,1: Field 1,2
1,0: Field 2,1
1,1: Field 2,2
Thanks and many Greetings
Michael
|