Re: [SOAP] Encoding arbitrary nested PHP arrays
| From: | David Busby | Date: | Sat, 04 Jan 2003 19:55:49 +0000 |
| Subject: | Re: [SOAP] Encoding arbitrary nested PHP arrays | ||
| References: | 1 | Groups: | php.soap |
| Request: | Send a blank email to php-soap+get-365@lists.php.net to get a copy of this message | ||
Antonio, List
Did you mean something that would recursively go over each value in the
array and do some odd work?
Could you try something link
function encode_array($ar)
foreach ($ar as $a)
if (is_array($a)) encode_array($a);
else
$sv = new SOAP_Value($key, $value, $type);
$params[] = $sv;
return $params[]
Then you can do in your code
$params = encode_array($my_ar);
$sc->call('array_method', $params);
Is that what you meant? Otherwise you can always serialize with the PHP
serialize function. Of course that only works if you have PHP on both ends
of wire.
/B
----- Original Message -----
From: "Antonio Ognio" <ognio@peruserver.com>
To: <soap@lists.php.net>
Sent: Friday, January 03, 2003 16:27
Subject: [SOAP] Encoding arbitrary nested PHP arrays
> Hello everybody,
>
> I'm new to the list and very happy to see we've
> now got quality libraries for working with SOAP
> using PHP.
>
> I've been studying the code of the SOAP pear
> module from CVS and can't figure out how to
> correctly encode an arbitrary array with
> elements that can be simple data types like
> integers and strings as well as other arrays.
>
>
> I've been playing with the decoding bits and
> it's pretty advanced, so decoding seems not
> to be a problem.
>
> My question is:
>
> If I have an arbitrary PHP array holding
> more simple types and other PHP arrays,
> how do I correctly generate a SOAP
> message with PEAR's SOAP module using
> SOAP's Schema encoding????
>
> I've seen there are some flags you can
> turn ON/OFF on the libraries and also
> that the current implementation prefers
> to map complex types into PHP Objects.
>
> My goal is to avoid having to previously
> define a class for handling the Struct,
> since it's the great flexibility of
> PHP's array what I use in my application
> and now all I need is to transport
> this arrays from one place to another
> using SOAP for RMI.
>
> Thanks a lot,
>
> Antonio Ognio
> Lima-Peru
>
>
> --
> PHP Soap Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php