Hello all
So, i use NuSOAP for PHP 5.3 and it work like a charm except that specificity. I can return strings, arrays, arrays of arrays, numbers, booleans, etc ... but i really have a problem with array of objects ! Is there something special i forgot to do ?
Here are the 2 versions of a simple function returning me an array of objects. The 1st one don't work. The 2nd one work :
1/ Don't work
function test()
{
$array = array();
for($i=0;$i<20;$i++)
{
$obj->ID = $i;
$obj->name = 'name'.$i;
$array[] = $obj;
}
return $array;
}
|
2/ Work
function test()
{
$array = array();
for($i=0;$i<20;$i++)
{
$obj->ID = $i;
$obj->name = 'name'.$i;
$array['some_string'.$i] = $obj;
}
return $array;
}
|
As you can see, i
have to specify a changing key for $array[]. This key
must be a string. Do you know why $array[] or $array[$i] don't work ?
(i simplified functions, $obj are always instanciate objects like $obj = new Myclass(); )
1st function worked with NuSOAP for PHP 5.2.8
Thanks a lot for any help