You are here

function xmlrpc_value in xmlrpc 8

Turns a data structure into objects with 'data' and 'type' attributes.

Parameters

mixed $data: The data structure.

string|bool $type: (optional) Type to assign to $data. Evaluated types are 'struct' and 'array'. FALSE will omit type casting.

Return value

object An XML-RPC data object containing the input $data.

2 calls to xmlrpc_value()
xmlrpc_request in ./xmlrpc.inc
Constructs an object representing an XML-RPC request.
xmlrpc_server in ./xmlrpc.server.inc
Invokes XML-RPC methods on this server.

File

./xmlrpc.inc, line 29
Drupal XML-RPC library.

Code

function xmlrpc_value($data, $type = FALSE) {
  $xmlrpc_value = new stdClass();
  $xmlrpc_value->data = $data;
  if (!$type) {
    $type = xmlrpc_value_calculate_type($xmlrpc_value);
  }
  $xmlrpc_value->type = $type;
  if ($type == 'struct') {

    // Turn all the values in the array into new xmlrpc_values.
    foreach ($xmlrpc_value->data as $key => $value) {
      $xmlrpc_value->data[$key] = xmlrpc_value($value);
    }
  }
  if ($type == 'array') {
    for ($i = 0, $j = count($xmlrpc_value->data); $i < $j; $i++) {
      $xmlrpc_value->data[$i] = xmlrpc_value($xmlrpc_value->data[$i]);
    }
  }
  return $xmlrpc_value;
}