<?xml version="1.0" encoding="utf-8" ?>
- <xml rows="5" code="cqssc" info="">
<row expect="20170607036" opencode="8,6,3,5,0" opentime="2017-06-07 12:00:40" />
</xml>
这是接口返回的数据
我希望能变成这样的数据,(20170607036====20170607-036)
<?xml version="1.0" encoding="utf-8" ?>
- <xml rows="5" code="cqssc" info="">
<row expect="20170607-036" opencode="8,6,3,5,0" opentime="2017-06-07 12:00:40" />
</xml>
接口地址http://f.apiplus.net/cqssc.xml 貌似服务器中才能打开
<?php
$s=file_get_contents("http://f.apiplus.net/cqssc.xml");
$xml=simplexml_load_string($s);
foreach($xml->children() as $child)
{
$c=$child["expect"];
$c1=substr($c,0,8).'-'.substr($c,-3,3);
$s=str_replace($c,$c1,$s);
}
echo $s;
?>
<?xml version="1.0" encoding="utf-8" ?>
晕,怎么只能法这点字