高价求 php把数组显示 成xml的代码
有个数组$str=array("1"=>array("qishu"=>14121812,"jianghao"=>10,11,07,06,02),"2"=>array("q...
有个数组
$str= array( "1" => array( "qishu" => 14121812 ,"jianghao" => 10,11,07,06,02 ),
"2" => array( "qishu" => 14121811 ,"jianghao" => 01,02,06,05,04 ) ,
"3" => array( "qishu" => 14121810 ,"jianghao" => 06,11,04,10,02 ),
"4" => array( "qishu" => 14121809 ,"jianghao" => 09,01,10,04,05 ) ,
"5" => array( "qishu" => 14121808 ,"jianghao" => 08,10,04,07,09 ) ,
"6" => array( "qishu" => 14121807 ,"jianghao" => 11,02,04,09,06 ));
想显示成这样的xml (下面的是源代码)
<?xml version="1.0" encoding="GBK"?>
<xml><row expect="2014121816" opencode="04,06,10,05,08" opentime="2014-12-18 11:30:20" /><row expect="2014121815" opencode="02,03,09,07,11" opentime="2014-12-18 11:20:20" /><row expect="2014121814" opencode="08,11,10,02,01" opentime="2014-12-18 11:10:20" /><row expect="2014121813" opencode="11,08,10,05,04" opentime="2014-12-18 11:00:20" /><row expect="2014121812" opencode="02,01,11,09,05" opentime="2014-12-18 10:50:20" /><row expect="2014121811" opencode="06,09,01,11,05" opentime="2014-12-18 10:40:20" /><row expect="2014121810" opencode="10,08,11,09,01" opentime="2014-12-18 10:30:20" /><row expect="2014121809" opencode="03,02,08,04,06" opentime="2014-12-18 10:20:20" /><row expect="2014121808" opencode="01,10,09,08,07" opentime="2014-12-18 10:10:20" /><row expect="2014121807" opencode="07,11,01,03,09" opentime="2014-12-18 10:00:20" /></xml> 展开
$str= array( "1" => array( "qishu" => 14121812 ,"jianghao" => 10,11,07,06,02 ),
"2" => array( "qishu" => 14121811 ,"jianghao" => 01,02,06,05,04 ) ,
"3" => array( "qishu" => 14121810 ,"jianghao" => 06,11,04,10,02 ),
"4" => array( "qishu" => 14121809 ,"jianghao" => 09,01,10,04,05 ) ,
"5" => array( "qishu" => 14121808 ,"jianghao" => 08,10,04,07,09 ) ,
"6" => array( "qishu" => 14121807 ,"jianghao" => 11,02,04,09,06 ));
想显示成这样的xml (下面的是源代码)
<?xml version="1.0" encoding="GBK"?>
<xml><row expect="2014121816" opencode="04,06,10,05,08" opentime="2014-12-18 11:30:20" /><row expect="2014121815" opencode="02,03,09,07,11" opentime="2014-12-18 11:20:20" /><row expect="2014121814" opencode="08,11,10,02,01" opentime="2014-12-18 11:10:20" /><row expect="2014121813" opencode="11,08,10,05,04" opentime="2014-12-18 11:00:20" /><row expect="2014121812" opencode="02,01,11,09,05" opentime="2014-12-18 10:50:20" /><row expect="2014121811" opencode="06,09,01,11,05" opentime="2014-12-18 10:40:20" /><row expect="2014121810" opencode="10,08,11,09,01" opentime="2014-12-18 10:30:20" /><row expect="2014121809" opencode="03,02,08,04,06" opentime="2014-12-18 10:20:20" /><row expect="2014121808" opencode="01,10,09,08,07" opentime="2014-12-18 10:10:20" /><row expect="2014121807" opencode="07,11,01,03,09" opentime="2014-12-18 10:00:20" /></xml> 展开
展开全部
$str = "<?xml version="1.0" encoding="GBK"?>
<xml>";
foreach循环数组拼接<row expect="2014121816" opencode="04,06,10,05,08" opentime="2014-12-18 11:30:20" />把里面的数据改成相对应的数组数据赋值,如
$str . ='<row expect="2014121816" opencode="04,06,10,05,08" opentime="2014-12-18 11:30:20" />';
循环结束,再
$str.="</xml>";
最后用PHP函数file_put_contents("test.xml",$str);
希望能帮助到你
<xml>";
foreach循环数组拼接<row expect="2014121816" opencode="04,06,10,05,08" opentime="2014-12-18 11:30:20" />把里面的数据改成相对应的数组数据赋值,如
$str . ='<row expect="2014121816" opencode="04,06,10,05,08" opentime="2014-12-18 11:30:20" />';
循环结束,再
$str.="</xml>";
最后用PHP函数file_put_contents("test.xml",$str);
希望能帮助到你
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询