class just{ function xmlInclude($data){ $xml = simplexml_load_file(dirname(__FILE__).'/jump.xml'); foreach($xml->Keyword->xpath("//*[data='$data']") as $item){ return $item; } }}$TR = new just;$cr = $TR->xmlInclude(查询);print_r($cr);$cr=(array)$cr;echo '
';print_r($cr);
SimpleXMLElement Object ( [data] => 查询 [page] => Array ( [0] => dbcon.php [1] => select.php [2] => footer.php ) ) Array ( [data] => 查询 [page] => Array ( [0] => dbcon.php [1] => select.php [2] => footer.php ) )
echo $cr[0].$cr[0][0].$cr[1][0]
$cr = $TR->xmlInclude(查询);echo $cr->data;echo $cr->page[1];
$cr = $TR->xmlInclude(查询);echo $cr->data;echo $cr->page[1];
$cr = $TR->xmlInclude(查询);
$cr=(array)$cr;
echo $cr['data'];
echo $cr['page'][1];
注意:$cr=(array)$cr; 只是将第一层对象转换成了数组
谢谢版主!~~
已抢65949个
抢已抢33194个
抢已抢18577个
抢已抢9133个
抢已抢11961个
抢已抢25226个
抢