convert_response_to_array ( $response )

Converts a SimpleXML response to an array structure.

Access

public

Parameters

Parameter

Type

Required

Description

$response

ResponseCore

Required

A response value.

Returns

Type

Description

array

The response value as a standard, multi-dimensional array.

Examples

Converts a SimpleXML response into a standard associative array.

// Get a ResponseCore response
$pas = new AmazonPAS();
$data = $pas->item_search('skillet awake');

// Convert SimpleXMLElement to Array.
$data = $pas->util->convert_response_to_array($data);

// Success?
var_dump($data['body']['Items']['Request']['ItemSearchRequest']['Keywords']);
Result:
string(13) "skillet awake"

Source

Method defined in utilities/utilities.class.php | Toggle source view (4 lines) | View on GitHub

public function convert_response_to_array(ResponseCore $response)
{
    return json_decode(json_encode($response), true);
}

Copyright © 2010–2013 Amazon Web Services, LLC


Feedback