时间:2021-07-01 10:21:17 帮助过:5人阅读
$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输出吧?
$s = "
$a = simplexml_load_string($s);
print_r($a);
比如 我要把所有
把
我是从配送公司获取的这个字符串。目的就是要把
//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 =<<< TXT10000000779460 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)