PHP Classes

File: helper/arrayToXml.php

Recommend this page to a friend!
  Classes of Alexey Starikov  >  PHP Helper Class  >  helper/arrayToXml.php  >  Download  
File: helper/arrayToXml.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Helper Class
Call helper functions that are loaded dynamically
Author: By
Last change: Add Example
Date: 3 years ago
Size: 1,679 bytes
 

Contents

Class file image Download
<?php
/*
arrayToXml
pear config-get php_dir
pear install XML_Serializer

??? ????????? UTF-8 ????? ????? ? ????? XML/Util.php:876 ?????????? ??????? isValidName
    ?????? 879
        if (!preg_match('/^[[:alpha:]_]\\z/u', mb_substr($string,0,1))) {
        # ???????? ??????????? u ? ????? ??????? ??????? ? UTF mb_substr($string,0,1) ?????? string{0}
    ?????? 887
        $match = preg_match(
            '/^([[:alpha:]_]([[:alnum:]\-\.]*)?:)?'
            . '[[:alpha:]_]([[:alnum:]\_\-\.]+)?\\z/u',# ???????? ??????????? u
            $string
        );
To support UTF-8 tags, you need to modify the isValidName function in the XML / Util.php file: 876
    line 879
        if (!preg_match('/^[[:alpha:]_]\\z/u', mb_substr($string,0,1))) {
        # add u modifier and select first character in UTF mb_substr($string,0,1) instead of string{0}
    line 887
        $match = preg_match(
            '/^([[:alpha:]_]([[:alnum:]\-\.]*)?:)?'
            . '[[:alpha:]_]([[:alnum:]\_\-\.]+)?\\z/u',# Add u modifier
            $string
        );
*/
return function ($array, $options = array(
       
"indent" => " ",
       
"linebreak" => "\n",
       
"typeHints" => false,
       
"addDecl" => true,
       
"encoding" => "UTF-8",
       
"rootName" => "root",
      
// "rootAttributes" => array("version" => "0.91"),
       
"defaultTagName" => "item",
       
"contentName" => "_content",
       
"attributesArray" => "_attributes"
   
)) {
    require_once
"XML/Serializer.php";
   
$serializer = new XML_Serializer($options);
    if (
$serializer->serialize($array)) {
        return
$serializer->getSerializedData();
    } else {
        return
null;
    }
}
?>

For more information send a message to info at phpclasses dot org.