Skip to content

Commit 84a55c0

Browse files
author
gr8b
committed
feature #59315 [Yaml] Add compact nested mapping support to Dumper
1 parent a316ae8 commit 84a55c0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

components/yaml.rst

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,38 @@ By default, digit-only array keys are dumped as integers. You can use the
440440
$dumped = Yaml::dump([200 => 'foo'], 2, 4, Yaml::DUMP_NUMERIC_KEY_AS_STRING);
441441
// '200': foo
442442

443+
Dumping Collection of Maps
444+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
445+
446+
By default, the collection of maps uses a hyphen on a separate line as a delimiter.
447+
To use the delimiter line as part of the map dump, use the ``Yaml::DUMP_COMPACT_NESTED_MAPPING`` flag.
448+
449+
Dump without flag set:
450+
451+
.. code-block:: text
452+
453+
planets:
454+
-
455+
name: Mercury
456+
distance: 57910000
457+
-
458+
name: Jupiter
459+
distance: 778500000
460+
461+
Dump with ``Yaml::DUMP_COMPACT_NESTED_MAPPING`` flag set:
462+
463+
.. code-block:: php
464+
465+
$dumped = Yaml::dump(['planets' => $planets], 2, 0, Yaml::DUMP_COMPACT_NESTED_MAPPING);
466+
467+
.. code-block:: text
468+
469+
planets:
470+
- name: Mercury
471+
distance: 57910000
472+
- name: Jupiter
473+
distance: 778500000
474+
443475
Syntax Validation
444476
~~~~~~~~~~~~~~~~~
445477

0 commit comments

Comments
 (0)