array(3)  { ["user"]=> string(8) "customer"  ["password"]=> string("/>  array(3)  { ["user"]=> string(8) "customer"  ["password"]=> string(">

Home  >  Article  >  Backend Development  >  多维PHP数组怎么转换成xml格式的数据

多维PHP数组怎么转换成xml格式的数据

WBOY
WBOYOriginal
2016-06-13 12:36:25996browse

多维PHP数组如何转换成xml格式的数据?
PHP数组是这样的:

array(4) <br />
{ <br />
	["auth"]=> array(3) <br />
	{<br />
		["user"]=> string(8) "customer" <br />
		["password"]=> string(8) "password" <br />
		["context"]=> string(1) "4" <br />
	} <br />
	["owner"]=> array(2) <br />
	{ <br />
		["user"]=> string(9) "customer2" <br />
		["context"]=> string(1) "4" <br />
	} <br />
	["language"]=> string(2) "en" <br />
	["task"]=> array(1) <br />
	{ <br />
		["code"]=> string(4) "0130" <br />
	} <br />
}


转换成xml格式后的数据格式是这样的:
<?xml version="1.0" encoding="utf-8"?><br />
<request><br />
	<auth><br />
		<user>customer</user><br />
		<password>password</password><br />
		<context>4</context><br />
	</auth><br />
	<owner><br />
		<user>customer2</user><br />
		<context>4</context><br />
	</owner><br />
	<language>en</language><br />
	<task><br />
		<code>0130</code><br />
	</task><br />
</request>

php数组 xml
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn