This function would be used by an XML-RPC server to convert PHP variables into an XML-RPC response.
It would be used within the PHP functions defined using xmlrpc_server_register_method()
Uses PHP variable reflection to assign the correct data types for the XML-RPC response. For example;
<?php
$params = array ( "one"=>"red","two"=>"blue","three"=>"green" );
$response = xmlrpc_encode ( $params );
echo ( $response );
?>
Produces;
<?xml version='1.0' encoding="utf-8" ?>
<params>
<param>
<value>
<struct>
<member>
<name>one</name>
<value>
<string>red</string>
</value>
</member>
<member>
<name>two</name>
<value>
<string>blue</string>
</value>
</member>
<member>
<name>three</name>
<value>
<string>green</string>
</value>
</member>
</struct>
</value>
</param>
</params>
While
<?php
$params = array ( "red", "blue", "green" );
$response = xmlrpc_encode ( $params );
echo ( $response );
?>
produces;
<?xml version='1.0' encoding="utf-8" ?>
<params>
<param>
<value>
<array>
<data>
<value>
<string>red</string>
</value>
<value>
<string>blue</string>
</value>
<value>
<string>green</string>
</value>
</data>
</array>
</value>
</param>
</params>
And
<?php
$params = 1;
$response = xmlrpc_encode ( $params );
echo ( $response );
?>
produces
<?xml version='1.0' encoding="utf-8" ?>
<params>
<param>
<value>
<int>1</int>
</value>
</param>
</params>
It's useful to be aware of the settype() function (http://www.php.net/settype).
For binary base64 data and XML-RPC iso8601 date times the xmlrpc_set_type() function should be used on a PHP variable before using xmlrpc_encode()