- XML code
<?xml version="1.0" encoding="utf-8"?> <user> <person_siteurl>http://www.163.com</person_siteurl> <job_keys>PHP</job_keys> <job_keys>JAVA</job_keys> <job_keys>PYTHON</job_keys> <email>jack@sina.com</email> </user>
以上是XML,怎么将里面的数据提取出来,结果如下:
- PHP code
$arr = array( 'person_siteurl'=>'http://www.163.com', 'job_keys'=>'php,java,python', 'email'=>'jack@sina.com' )
谢谢~~
------解决方案--------------------
- PHP code
$arr=(array)simplexml_load_file('user.xml'); $res=array_map(function($param){return is_array($param)?implode(',',$param):$param;},$arr); print_r($res);