I have a multidimensional array of form data thats an been unserialized from YAML. As such it looks something like this:
Array(
'name' => 'Somone',
'email' => '[email protected]',
'billing' => Array(
'address_1' => '1234 Somewhere'
'address_2' => NULL,
'city' => 'Somewhere',
'state' => 'ST'
'country' => 'CO'
'postal_code' => '12345'
),
'shipping' => Array(
'address_1' => '1234 Somewhere'
'address_2' => NULL,
'city' => 'Somewhere',
'state' => 'ST'
'country' => 'CO'
'postal_code' => '12345'
)
);
What i need to do is to flatten this so I can output some CSV, so it should look something like this:
Array(
'name' => 'Somone',
'email' => '[email protected]',
'billing_address_1' => '1234 Somewhere'
'billing_address_2' => NULL,
'billing_city' => 'Somewhere',
'billing_state' => 'ST'
'billing_country' => 'CO'
'billing_postal_code' => '12345'
'shipping_address_1' => '1234 Somewhere'
'shipping_address_2' => NULL,
'shipping_city' => 'Somewhere',
'shipping_state' => 'ST'
'shipping_country' => 'CO'
'shipping_postal_code' => '12345'
);
I will never know for sure how deep the array/hash is - it coul be only 2 levels as shown here or it could be 5.
Also this is in Symfony 1.4 so the sfForm with all of its luxuries is available if needed. I'm thinking there should be a sensible way to do this using the widget schema(s) and widgets. However, i would like to avoid binding the data back to the form if possible. This isn't part of the actual form submission process but is completely separate in an action for admins to download sets of the submitted data.