Submit xml request to any url in php

This topic will help php developer to submit request to any url using curl. In this example we will submit the xml data to the given url.


your accid data ';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$xmlcontent);

In the above request we are submitting the $xmlcontent to this “” url. Now $content is the response object i.e is in XML. We can convert it into array for flexibility of user requirements:


The above code will help you to convert xml data to an associative array. Hope the code will help to the php developer for curl request or convert xml to array in php. Thanks for reading the post.

Leave a Reply

Your email address will not be published. Required fields are marked *