国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁(yè) PHP 庫(kù) 其它類庫(kù) PHP數(shù)據(jù)格式與XML進(jìn)行轉(zhuǎn)換類
PHP數(shù)據(jù)格式與XML進(jìn)行轉(zhuǎn)換類
<?php
function xml2array($contents, $get_attributes = 1, $priority = 'tag') {
  if (!$contents) return array();
  if (!function_exists('xml_parser_create')) {
    // print "'xml_parser_create()' function not found!";
    return array();
  }
  // Get the XML parser of PHP - PHP must have this module for the parser to work
  $parser = xml_parser_create('');
  xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); // http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
  xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
  xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
  xml_parse_into_struct($parser, trim($contents), $xml_values);
  xml_parser_free($parser);
  if (!$xml_values) return; //Hmm...
  // Initializations
  $xml_array = array();
  $parents = array();
  $opened_tags = array();
  $arr = array();
  $current = &$xml_array; //Refference
  // Go through the tags.
  $repeated_tag_index = array(); //Multiple tags with same name will be turned into an array
  foreach($xml_values as $data) {
    unset($attributes, $value); //Remove existing values, or there will be trouble
    // This command will extract these variables into the foreach scope
    // tag(string), type(string), level(int), attributes(array).
    extract($data); //We could use the array by itself, but this cooler.
    $result = array();
    $attributes_data = array();
    if (isset($value)) {
      if ($priority == 'tag') $result = $value;
      else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode
    }

這是一個(gè)可以在XML和數(shù)據(jù)格式中互相轉(zhuǎn)換的類庫(kù),需要的朋友可以下載使用。

免責(zé)聲明

本站所有資源均由網(wǎng)友貢獻(xiàn)或各大下載網(wǎng)站轉(zhuǎn)載。請(qǐng)自行檢查軟件的完整性!本站所有資源僅供學(xué)習(xí)參考。請(qǐng)不要將它們用于商業(yè)目的。否則,一切后果由您負(fù)責(zé)!如有侵權(quán),請(qǐng)聯(lián)系我們刪除。聯(lián)系方式:admin@php.cn

相關(guān)文章

在將漢字?jǐn)?shù)據(jù)轉(zhuǎn)換為JSON格式時(shí),什么時(shí)候需要進(jìn)行Unicode轉(zhuǎn)換? 在將漢字?jǐn)?shù)據(jù)轉(zhuǎn)換為JSON格式時(shí),什么時(shí)候需要進(jìn)行Unicode轉(zhuǎn)換?

01 Apr 2025

漢字?jǐn)?shù)據(jù)轉(zhuǎn)JSON時(shí)Unicode轉(zhuǎn)換的時(shí)機(jī)探討在處理包含漢字的數(shù)據(jù)時(shí),將其轉(zhuǎn)換為JSON格式并存儲(chǔ)是一個(gè)常見需求。然...

LINQ 如何有效地將數(shù)據(jù)從寬格式轉(zhuǎn)換為高格式以進(jìn)行網(wǎng)格顯示? LINQ 如何有效地將數(shù)據(jù)從寬格式轉(zhuǎn)換為高格式以進(jìn)行網(wǎng)格顯示?

05 Jan 2025

使用 LINQ 透視數(shù)據(jù)在數(shù)據(jù)科學(xué)中,透視將數(shù)據(jù)從寬格式轉(zhuǎn)換為高格式,反之亦然。假設(shè)您有一個(gè)數(shù)據(jù)集...

如何在 PHP 中將列式數(shù)據(jù)結(jié)構(gòu)轉(zhuǎn)換為基于行的格式? 如何在 PHP 中將列式數(shù)據(jù)結(jié)構(gòu)轉(zhuǎn)換為基于行的格式?

25 Oct 2024

將多維列式數(shù)據(jù)重新排序?yàn)榛谛械慕Y(jié)構(gòu)給定一個(gè)具有面向列數(shù)據(jù)的關(guān)聯(lián)數(shù)組,任務(wù)是轉(zhuǎn)置...

如何使用自連接從自引用表中檢索數(shù)據(jù)? 如何使用自連接從自引用表中檢索數(shù)據(jù)?

13 Jan 2025

了解 SELF JOIN 及其應(yīng)用程序在數(shù)據(jù)庫(kù)管理領(lǐng)域中,SELF JOIN 是一種特殊類型的聯(lián)接操作,它允許...

在 Joomla 中連接第三方 PHP 庫(kù) 在 Joomla 中連接第三方 PHP 庫(kù)

28 Dec 2024

PHP 庫(kù)很方便,因?yàn)榭梢詮膽?yīng)用程序中的任何位置訪問(wèn)它們:從插件、組件模型、模塊等。如果有人已經(jīng)解決了類似的問(wèn)題并將其設(shè)計(jì)為庫(kù)(甚至更新了它),那就有意義了

Oracle 數(shù)據(jù)庫(kù)現(xiàn)在支持布爾數(shù)據(jù)類型嗎? Oracle 數(shù)據(jù)庫(kù)現(xiàn)在支持布爾數(shù)據(jù)類型嗎?

12 Jan 2025

Oracle 數(shù)據(jù)庫(kù)中布爾數(shù)據(jù)類型的可用性與其他 RDBMS(例如提供 BIT 數(shù)據(jù)類型的 Microsoft SQL Server)不同,Oracle 數(shù)據(jù)庫(kù)...

See all articles