时间:2021-07-01 10:21:17 帮助过:21人阅读
$str = "10000000779460 5 10000000779461 11 ";
htm;
preg_match_all("/<([^>]+)>([^<]+)<\/\\1>/U", $str, $matches);
$out = array();
foreach ($matches[1] as $key => $value) {
$out[$value][] = $matches[2][$key];
}
var_dump($out);
//xml 文件操作
$simXml = simplexml_load_file('xmlpath');
//取出orderNo
$orderNo = array();
foreach ($simXml->orderNo as $order)
{
$orderNo[] = (string)$order; //直接转换成字符串存放
}
//取出orderResult
$orderResult = array();
foreach ($simXml->orderResult as $res)
{
$orderResult[] = (string)$res;//直接转换成字符串存放,也可以转换成其他的;
}
$s =<<< TXT
10000000779460 5 10000000779461 11
TXT;
$d = array('orderNo' => 'array_order', 'orderResult' => 'arraresult');
preg_match_all('#<(orderNo
------解决方案--------------------
orderResult)>(.+)\1>#U', $s, $r);
foreach($r[1] as $i=>$k) ${$d[$k]}[] = $r[2][$i];
print_r($array_order);
print_r($arraresult);
Array
(
[0] => 10000000779460
[1] => 10000000779461
)
Array
(
[0] => 5
[1] => 11
)