Home > Backend Development > PHP Tutorial > PHP提取XML有关问题

PHP提取XML有关问题

WBOY
Release: 2016-06-13 10:15:47
Original
787 people have browsed it

PHP提取XML问题

XML code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><?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>[email protected]</email></user>
Copy after login

以上是XML,怎么将里面的数据提取出来,结果如下:
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$arr = array(   'person_siteurl'=>'http://www.163.com',   'job_keys'=>'php,java,python',    'email'=>[email protected]')
Copy after login



谢谢~~

------解决方案--------------------
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);<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template