I don't know anything about Java in PHP myself, but here's a function that will convert an object to an associative array for you.

function objToAssoc($obj) {
  if(is_object($obj)) {
    $arr = get_object_vars($obj);
  } else {
    $arr = $obj;
  if(is_array($arr)) {
    foreach($arr as $key => $val) {
      $arr[$key] = objToAssoc($val);
  return $arr;

Donovan Hutchinson wrote:


I've started putting together a site that uses PHP to access some custom
Java classes. While I'm not clear on what exactly the java classes are
doing, the programmer has given me an overview of the variables that I
should pass to them. However, I keep getting this error:

java.lang.IllegalArgumentException: argument type mismatch

The java programmer has no knowledge of PHP and so is unable to help locate
the source of the problem (tbh I'm don't have experience in large php
projects myself). The code I'm writing is in the following format:

$newobject = new Java('com.company.Class', $names, (String) $ssn, (int)

In the above example, $names is an object, $ssn a string and $time an
integer. The object $names is created in a similar way above this example.
Someone mentioned that I should be passing objects as arrays, but I'm not
clear on how this is done.

I've tested a very basic class to be sure it works, and had success, however
when I try to pass objects into classes, and multiple variables, it doesnt
work. I hope someone can shed some light on where I might be going wrong.

Many thanks,


paperCrane <Justin Patrin>
Question Everything, Reject Nothing

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to