请教高手了,江湖救急!!!!!!!!!!!!!!!!!!!! 如果节点名称都确定了,直接用windows 的替换可以吗?或者用正则表达式来做也可以啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $str = '<?xml version="1.0" encoding="GB2312"?><organization><orgUnit id="1" name="ÊÐ1¾Ö"/><orgUnit id="2" name="ÊÐ1¾Ö·Ö¾Ö" upid="1"/><orgUnit id="3" name="ÊÐ1¾Ö·Ö¾ÖµÄ·Ö¾Ö" upid="2"/><orgUnit id="4" name="ÊÐ2¾Ö"/><orgUnit id="5" name="ÊÐ2¾Ö·Ö¾Ö" upid="3"/></organization>';$id = array();$name = array();$upid = array();$tree = array();if (preg_match_all("/<orgUnit id=\"([0-9]+)\" name=\"(.+)\"( upid=\"([0-9]+)\"){0,1}\/>/isU", $str, $matches)) { $id = $matches[1]; $name = $matches[2]; $upid = $matches[4]; foreach ($id as $key => $val) { $parentId = ($upid[$key]) ? $upid[$key]: 0; $tree[$val] = array( 'id' => $val, 'parentId' => $parentId, 'name' => $name[$key] ); } print_r($tree);}$tree就是你要的结果树了 如果超过2秒没有打开刚返回false;可以实现吗? wml能否把一段内容复制到手机剪贴板中 Linux系统下,如何在Apache2中指定php.ini的路径 奇了怪了,session存不住,不知什么原因 PHP怎样快速入门(基础足够扎实) 更新数据表后怎么立即显示新的数据? 判断语句,请帮帮忙,谢谢 请问如何终止PHP脚本的运行? 之前问过,没得到答案,请大家再帮帮忙! 如何用正则表达式分离网页中html标签中的内容? phpadmin 为什么导入的数据(含中文) 都变成乱码了? 问一个简单的问题,请大家帮帮忙!
<organization>
<orgUnit id="1" name="ÊÐ1¾Ö"/>
<orgUnit id="2" name="ÊÐ1¾Ö·Ö¾Ö" upid="1"/>
<orgUnit id="3" name="ÊÐ1¾Ö·Ö¾ÖµÄ·Ö¾Ö" upid="2"/>
<orgUnit id="4" name="ÊÐ2¾Ö"/>
<orgUnit id="5" name="ÊÐ2¾Ö·Ö¾Ö" upid="3"/>
</organization>
';$id = array();
$name = array();
$upid = array();
$tree = array();if (preg_match_all("/<orgUnit id=\"([0-9]+)\" name=\"(.+)\"( upid=\"([0-9]+)\"){0,1}\/>/isU", $str, $matches)) {
$id = $matches[1];
$name = $matches[2];
$upid = $matches[4]; foreach ($id as $key => $val) {
$parentId = ($upid[$key]) ? $upid[$key]: 0;
$tree[$val] = array(
'id' => $val,
'parentId' => $parentId,
'name' => $name[$key]
);
} print_r($tree);}$tree就是你要的结果树了