I'll only put the part where I'm having problems!
The% w / w I need, needs to be in this format. Example 1:
Array
(
[atributos] => Array
(
[atributo] => Array
(
[nome] => Tamanho
[valor] => 35
),
[atributo] => Array
(
[nome] => Cor
[valor] => AZUL/ROSA
)
)
)
But the most I got close to was this! Example 2:
Array
(
[atributos] => Array
(
[atributo] => Array
(
[nome] => Cor
[valor] => AZUL/ROSA
)
)
)
Let's face the real problem if I have two or more attributes inside the array:
$arrayAtributos = array('Tamanho' => 35, 'Cor' => 'AZUL/ROSA');
When reading the% com_of%, so you can add the indexes and values next to the attributes / attribute
$arrayAtributos = array('Tamanho' => 35, 'Cor' => 'AZUL/ROSA');
foreach ($arrayAtributos as $nome => $valor) {
$xmlArray['atributos']['atributo']['nome'] = $nome;
$xmlArray['atributos']['atributo']['valor'] = $valor;
}
print_r($xmlArray);
Only the last index is added to the array, ignoring the rest, as if giving a group by name + value
How do you do it, so that all attributes are added within this multidimensional array using array
, as in the first example?
Full XML template and already being generated correctly with only one attribute!
But I need to add more attributes as in the example:
<atributos>
<atributo>
<nome>Tamanho</nome>
<valor>35</valor>
</atributo>
<atributo>
<nome>Cor</nome>
<valor>AZUL/ROSA</valor>
</atributo>
</atributos>
And is getting only with the last array attribute
<atributos>
<atributo>
<nome>Cor</nome>
<valor>AZUL/ROSA</valor>
</atributo>
</atributos>