关于你这个问题,我还是建议你用xml读取
这个是不会出错的
当然也可以用正则,不过如果items之间的属性位置变化了,我写的这个正则就不好用了,以下是保证属性位置不变的情况的例子,你把想得到的值,用foreach 循环$matches就可以
$xmlstr = @file_get_contents('data_show.xml');
$re='/
if(preg_match($re_total, $xmlstr, $mat)){
print_r($mat);
echo '
';
}
if(preg_match_all($re, $xmlstr, $matches)){
print_r($matches);
echo '
';
}
看手册
http://php.net/manual/en/book.xml.php
下边是用dom函数处理的文件,正则处理的写到你另一个帖子里了
关于控制数据,你在循环里边写个判断就可以 if($i>100)break;
$dom = new DOMDocument();
$dom->load('8888.xml');
$totalnode = $dom->getElementsByTagName('variable_total')->item(0);
echo $totalnode ->getAttribute('totalman').' ';
echo $totalnode ->getAttribute('totalmenoy').' ';
echo $totalnode ->getAttribute('totaljifen').'