NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Can't return an array of objects (NuSOAP PHP 5.3)


Joined: 20 Apr 2010
Posts: 2
Reply with quote
Hello all Smile

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

Code:

      function test()
      {
         $array = array();
         for($i=0;$i<20;$i++)
         {
            $obj->ID = $i;
            $obj->name = 'name'.$i;
            $array[] = $obj;
         }
         return $array;
      }


2/ Work

Code:

      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 Smile
View user's profileFind all posts by BubuSend private messageSend e-mail
Can't return an array of objects (NuSOAP PHP 5.3)
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic