Skip to content

Instantly share code, notes, and snippets.

@armetiz
Created November 24, 2011 14:42
Show Gist options
  • Save armetiz/1391489 to your computer and use it in GitHub Desktop.
Save armetiz/1391489 to your computer and use it in GitHub Desktop.
Symfony2.XmlEncoder
Encode : array ( array ( "property_name" => ""), array ( "property_name" => ""));
<response>
<item key="0"><property_name /></item>
<item key="1"><property_name /></item>
</response>
Encode : array ( array ("property_name" => array ( null, null, null ) ), array ("property_name" => array ( null, null, null ) ) );
<response>
<item key="0">
<property_name />
<property_name />
<property_name />
</item>
<item key="1">
<property_name />
<property_name />
</item>
</response>
In the XmlEncoder source code, a comment say : "Create nodes to append to $parentNode based on the $key of this array".
And, according to my pull-request, the result is more elegant :
Encode : array ( array ("property_name" => array ( null, null, null ) ), array ("property_name" => array ( null, null, null ) ) );
<response>
<item key="0">
<property_name>
<item key="0" />
<item key="1" />
<item key="2" />
</property_name>
</item>
<item key="1">
<property_name>
<item key="0" />
<item key="1" />
</property_name>
</item>
</response>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment