Danil Pyatnitsev
Danil Pyatnitsev

Reputation: 2292

Symfony Serialization component - serialize array with element and attribute

I trying to serialize an array with symfony's serialize component. I follow this manual

How to create following xml document:

<foo tag="bar">baz</foo>

My array to serialize:

['foo' => [@tag => 'bar', 'baz']]

but it creates folowing:

<foo tag="bar">
    <item key="0">baz</item>
</foo>

Upvotes: 0

Views: 349

Answers (1)

Srdjan
Srdjan

Reputation: 440

Create array in this way:

['foo' => ['@tag' => 'bar', '#' => 'baz']]

Upvotes: 3

Related Questions