laravel json to xml -


i need convert json format xml using laravel. i'm expecting output following.

   <message>     <authkey>your auth key</authkey>    <sender>senderid</sender>    <route>template</route>    <campaign>campaign name</campaign>    <country>country code</country>    <sms text="message1">    <address to="number1"></address>    </sms>    </message> 

the array tried convert is,

$text="hi mani"; $message=array("authkey"=>"68252aggui2sk45395d8f7", "route"=>"4","campaign"=>"test",         "sender"=>"oodoop","sms"=>array("text"=>$text,"address"=>array("-to"=>"8870300358")));     $json=array("message"=>$message);      $jsn=json_encode($json); 

this xml output json xml:

<?xml version="1.0" encoding="utf-8"?> <xml> <message>     <authkey>68252aggui2sk45395d8f7</authkey>     <route>4</route>     <campaign>test</campaign>     <sender>oodoop</sender>     <sms>         <text>hi mani</text>         <address><-to>8870300358         </-to>     </address> </sms> </message>undefined</xml> 

i got wrong output, tag mistake.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -