《PHP學(xué)習(xí):php操作xml并將其插入數(shù)據(jù)庫的實(shí)現(xiàn)方法》要點(diǎn):
本文介紹了PHP學(xué)習(xí):php操作xml并將其插入數(shù)據(jù)庫的實(shí)現(xiàn)方法,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
如下所示:PHP實(shí)例
<?php header('content-type:text/html;charset=utf-8'); mysql_connect('localhost', 'root', ''); mysql_select_db('test'); mysql_query('SET names utf8'); $xml_array=simplexml_load_file('suggest.xml'); //將XML中的數(shù)據(jù),讀取到數(shù)組對(duì)象中 foreach($xml_array as $tmp){ $sql = "insert into `countries` (`id` ,`value`) VALUES (NULL , '".$tmp->field."')"; mysql_query($sql); echo $tmp->field."<br>"; } ?>
以上這篇php操作xml并將其插入數(shù)據(jù)庫的實(shí)現(xiàn)方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持維易PHP.PHP實(shí)例
轉(zhuǎn)載請(qǐng)注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/3931.html