|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-04-16 06:59 UTC] r dot korving at xit dot nl
Description:
------------
Returning array('5' => 'Foo', '10' => 'Bar') from a SoapServer handler class ends up as array(0 => 'Foo', 1 => 'Bar') at the client end. But array('a' => 'Foo', 'b' => 'Bar') does end up correctly. It only fails with numeric keys. I'm not using WSDL in this case. I think integer keys that are not in a simple 0..n range should end up in an associative array, not indexed with new 0..n keys.
Reproduce code:
---------------
<?php
class MyHandler
{
public function getData()
{
return array('5' => 'Foo', '10' => 'Bar');
}
}
// initialize soap-server:
$soap = new SoapServer(null, array('uri' => 'http://uri/', 'encoding' => 'ISO-8859-1'));
$soap->setClass('MyHandler');
$soap->handle();
?>
Expected result:
----------------
array('5' => 'Foo', '10' => 'Bar')
Actual result:
--------------
array(0 => 'Foo', 1 => 'Bar')
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 19:00:01 2025 UTC |
Your expectation is wrong because PHP converts numeric string indeces into integer. $ sapi/cli/php -r 'var_dump(array("5" => "Foo", "10" => "Bar"));' array(2) { [5]=> string(3) "Foo" [10]=> string(3) "Bar" } BTW I fixed ext/soap to use Apache:Map instead of SOAP-ENC:Array in case of partial arrays (missing indeces). FIXED in CVS HEAD and PHP_5_2.