please help, merging arrays into an associative one
Posted on 2013-06-02
i have a form to add attributes to a product. when the user click on the "add attribute" button, he has a text field for the option name and a text field to assign this attribute position in the display order, and a button to add to this attribute values.
when this button is clicked, a table row appears with a text field for the value name (lets say that the option is color: so the value name can be red), a text field for its position in the display list and a text field for this value price, if it is wanted. and a remove button.
the form works fine, and i have managed to collect each value values into an array (with jquery to send via AJAX).
so lets say i have a post which looks like: $_POST['option_value_name'] which is an array like so:
array('0','1','2');// for the position
and so on.
now i want to merge those arrays, to make it easier to deal with the database in one loop.
merge_array - just indexical, so not fitting.
i tried array_combine, which is good but only allow 2 arrays.
is there a way to combine into an associative array with more then 2 arrays?
or maybe there is a better way to deal with my situation that i did not thought of?