<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="function.yaml-emit" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>yaml_emit</refname>
  <refpurpose>Returns the YAML representation of a value</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>string</type><methodname>yaml_emit</methodname>
   <methodparam><type>mixed</type><parameter>data</parameter></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>encoding</parameter><initializer>YAML_ANY_ENCODING</initializer></methodparam>
   <methodparam choice="opt"><type>int</type><parameter>linebreak</parameter><initializer>YAML_ANY_BREAK</initializer></methodparam>
   <methodparam choice="opt"><type>array</type><parameter>callbacks</parameter><initializer>&null;</initializer></methodparam>
  </methodsynopsis>
  <para>
   Generate a YAML representation of the provided <parameter>data</parameter>.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>data</parameter></term>
     <listitem>
      <para>
       The <parameter>data</parameter> being encoded. Can be any type except
       a <type>resource</type>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>encoding</parameter></term>
     <listitem>
      <para>
       Output character encoding chosen from
       <constant>YAML_ANY_ENCODING</constant>,
       <constant>YAML_UTF8_ENCODING</constant>,
       <constant>YAML_UTF16LE_ENCODING</constant>,
       <constant>YAML_UTF16BE_ENCODING</constant>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>linebreak</parameter></term>
     <listitem>
      <para>
       Output linebreak style chosen from
       <constant>YAML_ANY_BREAK</constant>,
       <constant>YAML_CR_BREAK</constant>,
       <constant>YAML_LN_BREAK</constant>,
       <constant>YAML_CRLN_BREAK</constant>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>callbacks</parameter></term>
     <listitem>
      <para>
       Content handlers for emitting YAML nodes. Associative <type>array</type>
       of classname =&gt; <type>callable</type> mappings. See
       <link linkend="yaml.callbacks.emit">emit callbacks</link> for more
       details.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns a YAML encoded <type>string</type> on success.
  </para>
 </refsect1>

 <refsect1 role="changelog">
  &reftitle.changelog;
  <para>
   <informaltable>
    <tgroup cols="2">
     <thead>
      <row>
       <entry>&Version;</entry>
       <entry>&Description;</entry>
      </row>
     </thead>
     <tbody>
      <row>
       <entry>PECL yaml 1.1.0</entry>
       <entry>
        The <parameter>callbacks</parameter> parameter was added.
       </entry>
      </row>
     </tbody>
    </tgroup>
   </informaltable>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>yaml_emit</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$addr = array(
    "given" => "Chris",
    "family"=> "Dumars",
    "address"=> array(
        "lines"=> "458 Walkman Dr.
        Suite #292",
        "city"=> "Royal Oak",
        "state"=> "MI",
        "postal"=> 48046,
      ),
  );
$invoice = array (
    "invoice"=> 34843,
    "date"=> 980208000,
    "bill-to"=> $addr,
    "ship-to"=> $addr,
    "product"=> array(
        array(
            "sku"=> "BL394D",
            "quantity"=> 4,
            "description"=> "Basketball",
            "price"=> 450,
          ),
        array(
            "sku"=> "BL4438H",
            "quantity"=> 1,
            "description"=> "Super Hoop",
            "price"=> 2392,
          ),
      ),
    "tax"=> 251.42,
    "total"=> 4443.52,
    "comments"=> "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.",
  );
var_dump(yaml_emit($invoice));
?>
]]>
    </programlisting>
    &example.outputs.similar;
    <screen>
<![CDATA[
string(628) "---
invoice: 34843
date: 980208000
bill-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
ship-to:
  given: Chris
  family: Dumars
  address:
    lines: |-
      458 Walkman Dr.
              Suite #292
    city: Royal Oak
    state: MI
    postal: 48046
product:
- sku: BL394D
  quantity: 4
  description: Basketball
  price: 450
- sku: BL4438H
  quantity: 1
  description: Super Hoop
  price: 2392
tax: 251.420000
total: 4443.520000
comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
...
"
]]>
    </screen>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>yaml_emit_file</function></member>
    <member><function>yaml_parse</function></member>
   </simplelist>
  </para>
 </refsect1>

</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
