XML_Serializer
[ class tree: XML_Serializer ] [ index: XML_Serializer ] [ all elements ]

Source for file serializeArrayWithObjects.php

Documentation is available at serializeArrayWithObjects.php

  1. <?PHP
  2. /**
  3.  * This example shows how to create an RDF document
  4.  * with a few lines of code.
  5.  * This can also be done with mode => simplexml
  6.  *
  7.  * @author Stephan Schmidt <schst@php.net>
  8.  * @see    serializeIndexedArray.php
  9.  */
  10.     error_reporting(E_ALL);
  11.  
  12.     require_once 'XML/Serializer.php';
  13.  
  14.     $options = array(
  15.                         "indent"          => "    ",
  16.                         "linebreak"       => "\n",
  17.                         "typeHints"       => false,
  18.                         "addDecl"         => true,
  19.                         "encoding"        => "UTF-8"
  20.                     );
  21.     
  22.     $serializer = new XML_Serializer($options);
  23.  
  24.     
  25.     $array = array(
  26.                     new stdClass(),
  27.                     new stdClass()
  28.                     );
  29.     
  30.     $result $serializer->serialize($array);
  31.     
  32.     if$result === true {
  33.         echo    "<pre>";
  34.         echo    htmlentities($serializer->getSerializedData());
  35.         echo    "</pre>";
  36.     }
  37.  
  38.     $result $serializer->serialize($arrayarray'classAsTagName' => true ));
  39.     
  40.     if$result === true {
  41.         echo    "<pre>";
  42.         echo    htmlentities($serializer->getSerializedData());
  43.         echo    "</pre>";
  44.     }
  45.     
  46. ?>

Documentation generated on Mon, 11 Mar 2019 13:55:03 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.