PHP XML数据解析代码[json,parser函数]

 更新时间:2016年11月25日 16:55  点击:2068
 代码如下 复制代码

//xml string
$xml_string="<?xml version='1.0'?>
<users>
<user id='398'>
<name>Foo</name>
<email>foo@bar.com</name>
</user>
<user id='867'>
<name>Foobar</name>
<email>foobar@foo.com</name>
</user>
</users>";

//load the xml string using simplexml
$xml = simplexml_load_string($xml_string);

//loop through the each node of user
foreach ($xml->user as $user)
{
//access attribute
echo $user['id'], ' ';
//subnodes are accessed by -> operator
echo $user->name, ' ';
echo $user->email, '<br />';
}

json数据解析代码

 

 代码如下 复制代码

$json_string='{"id":1,"name":"foo","email":"foo@foobar.com","interest":["wordpress","php"]} ';
$obj=json_decode($json_string);
echo $obj->name; //prints foo
echo $obj->interest[1]; //prints php


//xml string
$xml_string="<?xml version='1.0'?>
<users>
<user id='398'>
<name>Foo</name>
<email>foo@bar.com</name>
</user>
<user id='867'>
<name>Foobar</name>
<email>foobar@foo.com</name>
</user>
</users>";

//load the xml string using simplexml
$xml = simplexml_load_string($xml_string);

//loop through the each node of user
foreach ($xml->user as $user)
{
//access attribute
echo $user['id'], ' ';
//subnodes are accessed by -> operator
echo $user->name, ' ';
echo $user->email, '<br />';
}

php还自带了一个PHP XML Parser
PHP XML Parser 简介
XML 函数允许我们解析 XML 文档,但无法对其进行验证。

XML 是一种用于标准结构化文档交换的数据格式。您可以在我们的 XML 教程 中找到更多有关 XML 的信息。

该扩展使用 Expat XML 解析器。

Expat 是一种基于事件的解析器,它把 XML 文档视为一系列事件。当某个事件发生时,它调用一个指定的函数处理它。

Expat 是无验证的解析器,忽略任何链接到文档的 DTD。但是,如果文档的形式不好,则会以一个错误消息结束。

由于它基于事件,且无验证,Expat 具有快速并适合 web 应用程序的特性。

XML 解析器函数允许我们创建 XML 解析器,并为 XML 事件定义句柄。

在php中解析xml文档用专门的函数domdocument来处理,把json在php中也有相关的处理函数,我们要把数据xml 数据存到一个数据再用json_encode直接换成json数据就OK了。

/*
<?xml version='1.0' encoding='utf-8' ?>
<root cityid="0" classid="0" placeid="0" yy="0" mm="0" pg="1" ps教程="20" maxPage="1" num="1" serverIP="58.57.65.195">
<expo ID="3889" cityid="53" city="北京" classid="0" classname="建筑/装潢/五金" place="中国国际展览中心" placeid="0" tm1="2010-6-3" tm2="2010-6-5" title="20会" Address="北
里河路13号">
<![CDATA[2010北京第十五届中件系列]]>
</expo>
</root>

*/

<?php
$url = "http://www.111cn.net/xml.xml";

$dom = new DOMDocument();
$dom->load($url);
$root = $dom->documentElement;
$arr=array();
foreach ($root->childNodes as $item)
{
        if($item->hasChildNodes())
        {
                $tmp=array();
                foreach($item->childNodes as $one)
                {
                        $tmp[$one->tagName]=$one->nodeValue;
                }
               
                $arr[$item->tagName]=$tmp;
        }
}

$jsonStr = json_encode($arr);

var_dump($jsonStr);

/*

*/
?>

 
 */
 
 $epg_info = $_GET['epg_info'];
    $epg_info = urldecode($epg_info);
    print_r($epg_info);
    //echo $epg_info;
    //exit();

    $doc = new DOMDocument();
    $xml = file_get_contents($epg_info);     //这里是我新改过的
    $doc->loadXML($xml);
  $server_ip = $doc->getElementsByTagName("server_ip")->item(0)->nodeValue;
    $group_name = $doc->getElementsByTagName("group_name")->item(0)->nodeValue;
    $group_path = $doc->getElementsByTagName("group_path")->item(0)->nodeValue;
    $oss_user_id = $doc->getElementsByTagName("oss_user_id")->item(0)->nodeValue;
    $page_url = $doc->getElementsByTagName("page_url")->item(0)->nodeValue;
  
    echo 'server_ip:'. $server_ip.'<br>';
    echo 'group_name:'. $group_name.'<br>';
    echo 'group_path:'. $group_path.'<br>';
    echo 'oss_user_id:'. $oss_user_id.'<br>';
    echo 'page_url:'. $page_url.'<br>';

<?php

class rssGenerator_rss
{
    var $rss_version = '2.0';
    var $encoding = '';
    var $stylesheet = '';

    function cData($str)
    {
        return '<![CDATA[ ' . $str . ' ]]>';
    }

    function createFeed($channel)
    {
        $selfUrl = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on' ? 'http://' : 'https教程://');
        $selfUrl .= $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
        $rss = '<?xml version="1.0"';
        if (!empty($this->encoding)) {
            $rss .= ' encoding="' . $this->encoding . '"';
        }
        $rss .= '?>' . " ";
        if (!empty($this->stylesheet)) {
            $rss .= $this->stylesheet . " ";
        }
        $rss .= '<!-- Generated on ' . date('r') . ' -->' . " ";
        $rss .= '<rss version="' . $this->rss_version . '" xmlns:atom="http://www.w3.org/2005/Atom">' . " ";
        $rss .= '  <channel>' . " ";
     $rss .= '    <atom:link href="' . ($channel->atomLinkHref ? $channel->atomLinkHref : $selfUrl) . '" rel="self" type="application/rss+xml" />' . " ";
        $rss .= '    <title>' . $channel->title . '</title>' . " ";
        $rss .= '    <link>' . $channel->link . '</link>' . " ";
        $rss .= '    <description>' . $channel->description . '</description>' . " ";
        if (!empty($channel->language)) {
            $rss .= '    <language>' . $channel->language . '</language>' . " ";
        }
        if (!empty($channel->copyright)) {
            $rss .= '    <copyright>' . $channel->copyright . '</copyright>' . " ";
        }
        if (!empty($channel->managingEditor)) {
            $rss .= '    <managingEditor>' . $channel->managingEditor . '</managingEditor>' . " ";
        }
        if (!empty($channel->webMaster)) {
            $rss .= '    <webMaster>' . $channel->webMaster . '</webMaster>' . " ";
        }
        if (!empty($channel->pubDate)) {
            $rss .= '    <pubDate>' . $channel->pubDate . '</pubDate>' . " ";
        }
        if (!empty($channel->lastBuildDate)) {
            $rss .= '    <lastBuildDate>' . $channel->lastBuildDate . '</lastBuildDate>' . " ";
        }
        foreach ($channel->categories as $category) {
            $rss .= '    <category';
            if (!empty($category['domain'])) {
                $rss .= ' domain="' . $category['domain'] . '"';
            }
            $rss .= '>' . $category['name'] . '</category>' . " ";
        }
        if (!empty($channel->generator)) {
            $rss .= '    <generator>' . $channel->generator . '</generator>' . " ";
        }
        if (!empty($channel->docs)) {
            $rss .= '    <docs>' . $channel->docs . '</docs>' . " ";
        }
        if (!empty($channel->ttl)) {
            $rss .= '    <ttl>' . $channel->ttl . '</ttl>' . " ";
        }
        if (sizeof($channel->skipHours)) {
            $rss .= '    <skipHours>' . " ";
            foreach ($channel->skipHours as $hour) {
                $rss .= '      <hour>' . $hour . '</hour>' . " ";
            }
            $rss .= '    </skipHours>' . " ";
        }
        if (sizeof($channel->skipDays)) {
            $rss .= '    <skipDays>' . " ";
            foreach ($channel->skipDays as $day) {
                $rss .= '      <day>' . $day . '</day>' . " ";
            }
            $rss .= '    </skipDays>' . " ";
        }
        if (!empty($channel->image)) {
            $image = $channel->image;
            $rss .= '    <image>' . " ";
            $rss .= '      <url>' . $image->url . '</url>' . " ";
            $rss .= '      <title>' . $image->title . '</title>' . " ";
            $rss .= '      <link>' . $image->link . '</link>' . " ";
            if ($image->width) {
                $rss .= '      <width>' . $image->width . '</width>' . " ";
            }
            if ($image->height) {
                $rss .= '      <height>' . $image->height . '</height>' . " ";
            }
            if (!empty($image->description)) {
                $rss .= '      <description>' . $image->description . '</description>' . " ";
            }
            $rss .= '    </image>' . " ";
        }
        if (!empty($channel->textInput)) {
            $textInput = $channel->textInput;
            $rss .= '    <textInput>' . " ";
            $rss .= '      <title>' . $textInput->title . '</title>' . " ";
            $rss .= '      <description>' . $textInput->description . '</description>' . " ";
            $rss .= '      <name>' . $textInput->name . '</name>' . " ";
            $rss .= '      <link>' . $textInput->link . '</link>' . " ";
            $rss .= '    </textInput>' . " ";
        }
        if (!empty($channel->cloud_domain) || !empty($channel->cloud_path) || !empty($channel->cloud_registerProcedure) || !empty($channel->cloud_protocol)) {
            $rss .= '    <cloud domain="' . $channel->cloud_domain . '" ';
            $rss .= 'port="' . $channel->cloud_port . '" path="' . $channel->cloud_path . '" ';
            $rss .= 'registerProcedure="' . $channel->cloud_registerProcedure . '" ';
            $rss .= 'protocol="' . $channel->cloud_protocol . '" />' . " ";
        }
        if (!empty($channel->extraXML)) {
            $rss .= $channel->extraXML . " ";
        }
        foreach ($channel->items as $item) {
            $rss .= '    <item>' . " ";
            if (!empty($item->title)) {
                $rss .= '      <title>' . $item->title . '</title>' . " ";
            }
            if (!empty($item->description)) {
                $rss .= '      <description>' . $item->description . '</description>' . " ";
            }
            if (!empty($item->link)) {
                $rss .= '      <link>' . $item->link . '</link>' . " ";
            }
            if (!empty($item->pubDate)) {
                $rss .= '      <pubDate>' . $item->pubDate . '</pubDate>' . " ";
            }
            if (!empty($item->author)) {
                $rss .= '      <author>' . $item->author . '</author>' . " ";
            }
            if (!empty($item->comments)) {
                $rss .= '      <comments>' . $item->comments . '</comments>' . " ";
            }
            if (!empty($item->guid)) {
                $rss .= '      <guid isPermaLink="';
                $rss .= ($item->guid_isPermaLink ? 'true' : 'false') . '">';
                $rss .= $item->guid . '</guid>' . " ";
            }
            if (!empty($item->source)) {
                $rss .= '      <source url="' . $item->source_url . '">';
                $rss .= $item->source . '</source>' . " ";
            }
            if (!empty($item->enclosure_url) || !empty($item->enclosure_type)) {
                $rss .= '      <enclosure url="' . $item->enclosure_url . '" ';
                $rss .= 'length="' . $item->enclosure_length . '" ';
                $rss .= 'type="' . $item->enclosure_type . '" />' . " ";
            }
            foreach ($item->categories as $category) {
                $rss .= '      <category';
                if (!empty($category['domain'])) {
                    $rss .= ' domain="' . $category['domain'] . '"';
                }
                $rss .= '>' . $category['name'] . '</category>' . " ";
            }
            $rss .= '    </item>' . " ";
        }
        $rss .= '  </channel>' . " ";
        return $rss .= '</rss>';
    }

}

class rssGenerator_channel
{
    var $atomLinkHref = '';
    var $title = '';
    var $link = '';
    var $description = '';
    var $language = '';
    var $copyright = '';
    var $managingEditor = '';
    var $webMaster = '';
    var $pubDate = '';
    var $lastBuildDate = '';
    var $categories = array();
    var $generator = '';
    var $docs = '';
    var $ttl = '';
    var $image = '';
    var $textInput = '';
    var $skipHours = array();
    var $skipDays = array();
    var $cloud_domain = '';
    var $cloud_port = '80';
    var $cloud_path = '';
    var $cloud_registerProcedure = '';
    var $cloud_protocol = '';
    var $items = array();
    var $extraXML = '';

}

class rssGenerator_image
{
    var $url = '';
    var $title = '';
    var $link = '';
    var $width = '88';
    var $height = '31';
    var $description = '';

}

class rssGenerator_textInput
{
    var $title = '';
    var $description = '';
    var $name = '';
    var $link = '';

}

class rssGenerator_item
{
    var $title = '';
    var $description = '';
    var $link = '';
    var $author = '';
    var $pubDate = '';
    var $comments = '';
    var $guid = '';
    var $guid_isPermaLink = true;
    var $source = '';
    var $source_url = '';
    var $enclosure_url = '';
    var $enclosure_length = '0';
    var $enclosure_type = '';
    var $categories = array();

}

?>

实例

<?php

require_once 'rss_generator.inc.php';

$rss_channel = new rssGenerator_channel();
$rss_channel->atomLinkHref = '';
$rss_channel->title = 'My News';
$rss_channel->link = 'http://111cn.net教程/news.php';
$rss_channel->description = 'The latest news about web-development.';
$rss_channel->language = 'en-us';
$rss_channel->generator = 'PHP RSS Feed Generator';
$rss_channel->managingEditor = 'editor@mysite.com (Alex Jefferson)';
$rss_channel->webMaster = 'webmaster@mysite.com (Vagharshak Tozalakyan)';

$item = new rssGenerator_item();
$item->title = 'New website launched';
$item->description = 'Today I finaly launch a new website.';
$item->link = 'http://111cn.net';
$item->guid = 'http://111cn.net';
$item->pubDate = 'Tue, 07 Mar 2006 00:00:01 GMT';
$rss_channel->items[] = $item;

$item = new rssGenerator_item();
$item->title = 'Another website launched';
$item->description = 'Just another website launched.';
$item->link = 'http://111cn.net';
$item->guid = 'http://111cn.net';
$item->pubDate = 'Wed, 08 Mar 2006 00:00:01 GMT';
$rss_channel->items[] = $item;

$rss_feed = new rssGenerator_rss();
$rss_feed->encoding = 'UTF-8';
$rss_feed->version = '2.0';
header('Content-Type: text/xml');
echo $rss_feed->createFeed($rss_channel);

?>

<?php

class rss74 {

    // RSS feed title:
    var $title = "Untitled";
   
    // RSS description:
    var $desc = "";
   
    // RSS base url
    // -> Example: http://www.jonasjohn.de/
    var $base_url = "";
   
    // XSL file for the resulting RSS feed:
    var $xsl_file = 'rss.xsl';
   
    // RSS 2.0 Specification (URL):
    var $doc_url = 'http://blogs.law.harvard.edu/tech/rss';
   
    // Copyright text:
    // -> Example: Copyright 2006, Jonas John
    var $copyright = '';
   
    // RSS language setting:
    // Example: en-us, de-de, fr-fr
    var $language = 'en-us';
   
    // Managing editor and webmaster:
    // (should contain a E-Mail adress)
    var $managing_editor = '';
    var $webmaster = '';
   
    // Feedburner URL
    // Example: http://feeds.feedburner.com/codedump-rss
    // (If a FB URL is set, all requests except the Feedburner and Google
    // requests will be redricted to the feedburner URL)
    var $feedburner_url = '';
   
    // RSS generator:
    var $generator = 'rss74/v0.3';
   
    // Limit RSS entries to:
    // (Example: 20, 30, 40, 50, etc.)
    var $limit_entries = 20;

    // RSS items:
    var $items = array();

    // constructor:
    function rss74(){
    }  
   
    function add_entry($entry){   
   
        // create date key:
        $date = isset($entry['date']) ? $entry['date'] : time();  

        // add unique string:
        $date .= '_' . md5($entry['title']);
       
        $this->items[$date] = $entry;
    }
   
    function _get_val(&$array, $key){
        return isset($array[$key]) ? $array[$key] : '';
    }
   
    function _exists_val(&$array, $key){
        return isset($array[$key]);
    }
   
    function get_rss_headers($rss_webpath){
        return '<link rel="alternate" type="application/rss+xml" title="RSS" href="'.$rss_webpath.'" />';
    }
   
    function print_rss(){
        global $_SERVER;
   
        krsort($this->items);
        $this->items = array_slice($this->items, 0, $this->limit_entries);
       
        $first_item = array_keys($this->items);
        $first_item = $first_item[0];
       
        $last_change = $this->items[$first_item]['date'];
        header('Last-Modified: '.gmdate('D, d M Y H:i:s', $last_change).' GMT');
       
        header('Content-Type: text/xml; charset=utf-8');

        if (!empty($this->feedburner_url)){
            if (!preg_match("/feedburner/i", $_SERVER['HTTP_USER_AGENT']) and !preg_match("/google/i", $_SERVER['HTTP_USER_AGENT'])) {
                header('HTTP/1.1 301 Moved Permanently');
                header('Location: ' . $this->feedburner_url);
                print '<a href="'.$this->feedburner_url.'">Redirecting...</a>';
                return true;
            }
        }

        print '<?xml version="1.0" encoding="utf-8"?>' . " ";
       
        if ($this->xsl_file != '')
            print '<?xml-stylesheet href="rss.xsl" type="text/xsl" media="screen"?>' . " ";
       
        print '<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>' . " ";
       
        print "<!-- Hello! This web page is a RSS file that is meant to be read by a RSS reader application. Look at http://en.wikipedia.org/wiki/RSS to learn more about RSS. -->";
       
        print '<rss version="2.0" xmlns:xhtml="http://www.w3.org/1999/xhtml">' . " ";
        print '<channel>' . " ";
       
        print " ".'<title>'.htmlentities($this->title).'</title>' . " ";
       
        if (!empty($this->desc))
            print " ".'<description>'.htmlentities($this->desc).'</description>' . " ";
       
        if (!empty($this->base_url))
            print " ".'<link>'.htmlentities($this->base_url).'</link>' . " ";
       
        print " ".'<lastBuildDate>'.date('r', time()).'</lastBuildDate>' . " ";
        print " ".'<pubDate>'.date('r', time()).'</pubDate>' . " ";
       
        if (!empty($this->generator))
            print " ".'<generator>'.$this->generator.'</generator>' . " ";
       
        if (!empty($this->copyright))
            print " ".'<copyright>'.$this->copyright.'</copyright>' . " ";
           
        if (!empty($this->doc_url))
            print " ".'<docs>'.$this->doc_url.'</docs>' . " ";
       
        if (!empty($this->language))
            print " <language>".$this->language."</language> ";
           
        if (!empty($this->managing_editor))
            print " <managingEditor>".$this->managing_editor."</managingEditor> ";

        if (!empty($this->webmaster))
            print " <webMaster>".$this->webmaster."</webMaster> ";


        while(list($num, $item) = each($this->items)){
     
            print " <item> ";
            print " <title>".htmlentities($this->_get_val($item, 'title'))."</title> ";
           
            if ($this->_exists_val($item, 'url')){
                print " <link>".$this->_get_val($item, 'url')."</link> ";
                print " <guid isPermaLink="true">".$this->_get_val($item, 'url')."</guid> ";
            }
           
            if ($this->_exists_val($item, 'desc'))
                print " <description><![CDATA[".$this->_get_val($item, 'desc')."]]></description> ";
           
            if ($this->_exists_val($item, 'date')){
                print " <pubDate>".date('r', intval($this->_get_val($item, 'date')))."</pubDate> ";
            }
       
            $cats = array();
            while(list($cn, $citem) = each($cats)){
                print " <category>$citem</category> ";
            }
               
            print " </item> ";
            
        }

        print " </channel> ";
        print "</rss>";
       
        return true;
       
    }
}

实例

 include('inc.rss74.php');

    // RSS items list:
    $example_list = array();   
       
    /*
    ** Create some test entries:
    */
   
    $m = rand(8, 30);
    for ($x = 0; $x < $m; $x++){
   
        // create a random UNIX-Timestamp:
        $date = rand(1166000000, 1166400000);
   
        $example_list[] = array(
            'title' => 'Example RSS message #' . $x,
            'url' => 'http://www.jonasjohn.de/#' . $x,
            'desc' => 'This is a example message from RSS74!',
            'date' => $date
        );
   
    }
   
   
    // create new RSS object:
    $rss = new rss74();
   
    /*
    ** Set RSS informations:
    */
   
    // RSS title:
    $rss->title = 'RSS example 2';
   
    // RSS description:
    $rss->desc = 'This feed shows some random entries.';
   
    // base URL of your homepage:
    $rss->base_url = 'http://www.example.org/';
   
    // limit entry count to 20
    $rss->limit_entries = 20;
   
    // RSS Editor
    $rss->managing_editor = 'Yourname <yourname@example.org>';

    // Webmaster name
    $rss->webmaster = 'Yourname <yourname@example.org>';
   
    // language:
    $rss->language = 'en-us';
   
    // Copyright message:
    $rss->copyright = 'Copyright 2006, Yourname';
   
    // Set Feedburner adress:
    //$rss->feedburner_url = 'http://feeds.feedburner.com/codedump-rss';
    // (empty) = No redirection

    // Set "xsl_file" to empty to disable the XSL file:
    $rss->xsl_file = '';

    // Add entries to the RSS object:
    while (list($date, $entry) = each($example_list)){
              
        $rss->add_entry(array(
            'title'     => $entry['title'],
            'url'       => $entry['url'],
            'desc'      => $entry['desc'],
            'date'      => $entry['date']
        ));
   
    }
   
    // let rss74 do the rest:
    $rss->print_rss();

?>

 

[!--infotagslink--]

相关文章

  • php正确禁用eval函数与误区介绍

    eval函数在php中是一个函数并不是系统组件函数,我们在php.ini中的disable_functions是无法禁止它的,因这他不是一个php_function哦。 eval()针对php安全来说具有很...2016-11-25
  • php中eval()函数操作数组的方法

    在php中eval是一个函数并且不能直接禁用了,但eval函数又相当的危险了经常会出现一些问题了,今天我们就一起来看看eval函数对数组的操作 例子, <?php $data="array...2016-11-25
  • Python astype(np.float)函数使用方法解析

    这篇文章主要介绍了Python astype(np.float)函数使用方法解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-06-08
  • C#连接SQL数据库和查询数据功能的操作技巧

    本文给大家分享C#连接SQL数据库和查询数据功能的操作技巧,本文通过图文并茂的形式给大家介绍的非常详细,需要的朋友参考下吧...2021-05-17
  • php简单数据操作的实例

    最基础的对数据的增加删除修改操作实例,菜鸟们收了吧...2013-09-26
  • Python中的imread()函数用法说明

    这篇文章主要介绍了Python中的imread()函数用法说明,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-16
  • 解决Mybatis 大数据量的批量insert问题

    这篇文章主要介绍了解决Mybatis 大数据量的批量insert问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-01-09
  • C# 中如何取绝对值函数

    本文主要介绍了C# 中取绝对值的函数。具有很好的参考价值。下面跟着小编一起来看下吧...2020-06-25
  • Antd-vue Table组件添加Click事件,实现点击某行数据教程

    这篇文章主要介绍了Antd-vue Table组件添加Click事件,实现点击某行数据教程,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2020-11-17
  • C#学习笔记- 随机函数Random()的用法详解

    下面小编就为大家带来一篇C#学习笔记- 随机函数Random()的用法详解。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2020-06-25
  • 详解如何清理redis集群的所有数据

    这篇文章主要介绍了详解如何清理redis集群的所有数据,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-02-18
  • 不打开网页直接查看网站的源代码

      有一种方法,可以不打开网站而直接查看到这个网站的源代码..   这样可以有效地防止误入恶意网站...   在浏览器地址栏输入:   view-source:http://...2016-09-20
  • php 调用goolge地图代码

    <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
  • vue 获取到数据但却渲染不到页面上的解决方法

    这篇文章主要介绍了vue 获取到数据但却渲染不到页面上的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-11-19
  • JS基于Mootools实现的个性菜单效果代码

    本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
  • php把读取xml 文档并转换成json数据代码

    在php中解析xml文档用专门的函数domdocument来处理,把json在php中也有相关的处理函数,我们要把数据xml 数据存到一个数据再用json_encode直接换成json数据就OK了。...2016-11-25
  • JS+CSS实现分类动态选择及移动功能效果代码

    本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
  • JS实现自定义简单网页软键盘效果代码

    本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
  • mybatis-plus 处理大数据插入太慢的解决

    这篇文章主要介绍了mybatis-plus 处理大数据插入太慢的解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-12-18
  • php 取除连续空格与换行代码

    php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25