Jump to content

Numeric array values reindex in SOAP response.


james_preece2000

Recommended Posts

I'm having difficulty sending array data over SOAP, I have my SOAP server set up and have been sending data find and dandy and my app is coming along nicely but I've just come across the following anomaly.

If I set:

$foo[a] = "test"
$foo[b] = "test"
return $foo;

The response at the other end will print_r as:

Array
(
    [a] => "test"
    [b] => "test"
)

This is what I expected. However, if I send:

$foo[50] = "test"
$foo[99] = "test"

It will print_r as:

Array
(
    [0] => "test"
    [1] => "test"
)

The numeric index has been reindexed from zero. However, if I do this:

$foo[50] = "test"
$foo[99] = "test"
$foo[a] = "test"

The response is NOT reindexed:

Array
(
    [50] => "test"
    [99] => "test"
    [a] => "test"
)

No amount of $foo["99"] making it a string type efforts will fix it, all the keys of the array could be stored as an INT then they are not sent and they are re-indexed at the other end.

Has anybody seen this problem before? I would like to use the keys to send ID values of users but I cannot if they will be reindexed!

Thanks for your time.

James

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.