3
Assuming I have the following array
array(
'chave1' => 'valor1',
'chave2' => array(
'chave3' => 'valor2',
'chave4' => array(
'chave5' => 'valor3'
)
))
And in this array I need to set the value of key 5, but without going level by level, I could move to a function like this :
setar_valor('chave2.chave4.chave5', 'meu novo valor');
And this function would interpret that each . would be a new level inside the array.
I’ve broken my head with it, but I can’t think of how to do it :/
Cakephp organizes exactly this way, I’ll see how they do it, I’ll look in the documentation
– Erlon Charles
It is necessary to interpret
chave2.chave4.chave5by dividing each level by.? it wouldn’t be easier to go all the way array and change the value according to the key?– stderr
@qmechanik would be easier yes, but would have conflict if you have more than one 5 key at different array levels
– Lucas Pires