PHP5 and arrays of complextype

Hi,

I am currently having the exact same problem as described here:

http://bugs.php.net/bug.php?id=36226

The webservice is configured to return 0-* objects of a complextype,
but when only one single item is returned, it does not get deserialized
as an array as I would expect, but as a single object.

The new feature proposed on the bottom of the above page does not seem
to be included in our installed version of PHP 5.1.2-1.

Is there any other way to change this behaviour.

Kind regards.
gerry.vandermaesen [ Do, 11 Januar 2007 10:56 ] [ ID #1592415 ]

Re: PHP5 and arrays of complextype

"Gerry Vandermaesen" <gerry.vandermaesen [at] gmail.com> wrote in message
news:1168509369.708206.125320 [at] i56g2000hsf.googlegroups.com.. .
| Hi,
|
| I am currently having the exact same problem as described here:
|
| http://bugs.php.net/bug.php?id=36226
|
| The webservice is configured to return 0-* objects of a complextype,
| but when only one single item is returned, it does not get deserialized
| as an array as I would expect, but as a single object.
|
| The new feature proposed on the bottom of the above page does not seem
| to be included in our installed version of PHP 5.1.2-1.
|
| Is there any other way to change this behaviour.
|
| Kind regards.

$complexType = yourCallToWebService;
if (!is_array($complexType)){ $complexType = array($complexType); }

perhaps? haven't played with that too much.
Steve [ Do, 11 Januar 2007 19:18 ] [ ID #1592480 ]

Re: PHP5 and arrays of complextype

Steve wrote:
> "Gerry Vandermaesen" <gerry.vandermaesen [at] gmail.com> wrote in message
> news:1168509369.708206.125320 [at] i56g2000hsf.googlegroups.com.. .
> | Hi,
> |
> | I am currently having the exact same problem as described here:
> |
> | http://bugs.php.net/bug.php?id=36226
> |
> | The webservice is configured to return 0-* objects of a complextype,
> | but when only one single item is returned, it does not get deserialized
> | as an array as I would expect, but as a single object.
> |
> | The new feature proposed on the bottom of the above page does not seem
> | to be included in our installed version of PHP 5.1.2-1.
> |
> | Is there any other way to change this behaviour.
> |
> | Kind regards.
>
> $complexType = yourCallToWebService;
> if (!is_array($complexType)){ $complexType = array($complexType); }
>
> perhaps? haven't played with that too much.
>
>

Because it is an array of arrays, simply checking is_array will always
return true.
Now assuming that the second array is associated array as described in
the bugs,
the following code **might** do the trick

$complexType = yourCallToWebService;
if(array_key_exist('id', $complexType)) $complexType = array($complexType);

Hendri Kurniawan
Hendri Kurniawan [ Do, 11 Januar 2007 23:01 ] [ ID #1592484 ]

Re: PHP5 and arrays of complextype

"Gerry Vandermaesen" <gerry.vandermaesen [at] gmail.com> wrote in message
news:1168509369.708206.125320 [at] i56g2000hsf.googlegroups.com.. .
| Hi,
|
| I am currently having the exact same problem as described here:
|
| http://bugs.php.net/bug.php?id=36226
|
| The webservice is configured to return 0-* objects of a complextype,
| but when only one single item is returned, it does not get deserialized
| as an array as I would expect, but as a single object.
|
| The new feature proposed on the bottom of the above page does not seem
| to be included in our installed version of PHP 5.1.2-1.
|
| Is there any other way to change this behaviour.
|
| Kind regards.

$complexType = yourCallToWebService;
if (!is_array($complexType)){ $complexType = array($complexType); }

perhaps? haven't played with that too much.
Steve [ Do, 11 Januar 2007 19:18 ] [ ID #1592511 ]

Re: PHP5 and arrays of complextype

Steve wrote:
> "Gerry Vandermaesen" <gerry.vandermaesen [at] gmail.com> wrote in message
> news:1168509369.708206.125320 [at] i56g2000hsf.googlegroups.com.. .
> | Hi,
> |
> | I am currently having the exact same problem as described here:
> |
> | http://bugs.php.net/bug.php?id=36226
> |
> | The webservice is configured to return 0-* objects of a complextype,
> | but when only one single item is returned, it does not get deserialized
> | as an array as I would expect, but as a single object.
> |
> | The new feature proposed on the bottom of the above page does not seem
> | to be included in our installed version of PHP 5.1.2-1.
> |
> | Is there any other way to change this behaviour.
> |
> | Kind regards.
>
> $complexType = yourCallToWebService;
> if (!is_array($complexType)){ $complexType = array($complexType); }
>
> perhaps? haven't played with that too much.
>
>

Because it is an array of arrays, simply checking is_array will always
return true.
Now assuming that the second array is associated array as described in
the bugs,
the following code **might** do the trick

$complexType = yourCallToWebService;
if(array_key_exist('id', $complexType)) $complexType = array($complexType);

Hendri Kurniawan
Hendri Kurniawan [ Do, 11 Januar 2007 23:01 ] [ ID #1592529 ]

Re: PHP5 and arrays of complextype

"Hendri Kurniawan" <ask-me [at] email.com> wrote in message
news:12qdcu63ij1tgcc [at] corp.supernews.com...
| Steve wrote:
| > "Gerry Vandermaesen" <gerry.vandermaesen [at] gmail.com> wrote in message
| > news:1168509369.708206.125320 [at] i56g2000hsf.googlegroups.com.. .
| > | Hi,
| > |
| > | I am currently having the exact same problem as described here:
| > |
| > | http://bugs.php.net/bug.php?id=36226
| > |
| > | The webservice is configured to return 0-* objects of a complextype,
| > | but when only one single item is returned, it does not get
deserialized
| > | as an array as I would expect, but as a single object.
| > |
| > | The new feature proposed on the bottom of the above page does not seem
| > | to be included in our installed version of PHP 5.1.2-1.
| > |
| > | Is there any other way to change this behaviour.
| > |
| > | Kind regards.
| >
| > $complexType = yourCallToWebService;
| > if (!is_array($complexType)){ $complexType = array($complexType); }
| >
| > perhaps? haven't played with that too much.
| >
| >
|
| Because it is an array of arrays, simply checking is_array will always
| return true.

interesting. i had thought that if $complexType was nothing (an unitialized
array for instance), that declaring an array initialized with nothing
(uninitialized array - $complexType) would make the array be likewise
uninitialized. i'll have to check that...just hadn't run across that before.
thanks for the heads-up.
Steve [ Fr, 12 Januar 2007 01:48 ] [ ID #1593510 ]

Re: PHP5 and arrays of complextype

"Hendri Kurniawan" <ask-me [at] email.com> wrote in message
news:12qdcu63ij1tgcc [at] corp.supernews.com...
| Steve wrote:
| > "Gerry Vandermaesen" <gerry.vandermaesen [at] gmail.com> wrote in message
| > news:1168509369.708206.125320 [at] i56g2000hsf.googlegroups.com.. .
| > | Hi,
| > |
| > | I am currently having the exact same problem as described here:
| > |
| > | http://bugs.php.net/bug.php?id=36226
| > |
| > | The webservice is configured to return 0-* objects of a complextype,
| > | but when only one single item is returned, it does not get
deserialized
| > | as an array as I would expect, but as a single object.
| > |
| > | The new feature proposed on the bottom of the above page does not seem
| > | to be included in our installed version of PHP 5.1.2-1.
| > |
| > | Is there any other way to change this behaviour.
| > |
| > | Kind regards.
| >
| > $complexType = yourCallToWebService;
| > if (!is_array($complexType)){ $complexType = array($complexType); }
| >
| > perhaps? haven't played with that too much.
| >
| >
|
| Because it is an array of arrays, simply checking is_array will always
| return true.

interesting. i had thought that if $complexType was nothing (an unitialized
array for instance), that declaring an array initialized with nothing
(uninitialized array - $complexType) would make the array be likewise
uninitialized. i'll have to check that...just hadn't run across that before.
thanks for the heads-up.
Steve [ Fr, 12 Januar 2007 01:48 ] [ ID #1593641 ]
PHP » alt.php » PHP5 and arrays of complextype

Vorheriges Thema: PHP/mySQL/Apache installation on Win98
Nächstes Thema: select box