<?php
$json = '{
"title1": {
"key1": "value1",
"key2": "value2",
"key3": "value3"
},
"title2": {
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
}';
if (!$decodificado) {
}
//$title pega o title1 e title2, title3, etc
foreach ($decodificado as &$title) {
//$value pega o valor key1, key3, key3, key4, etc
foreach ($title as $key => &$value) {
//Aqui um exemplo para alterar as chaves com nome key2 e key3 apenas
if ($key === 'key2') {
} elseif ($key === 'key3') {
}
}
}
PD9waHAKCiRqc29uID0gJ3sKICAgICJ0aXRsZTEiOiB7CiAgICAgICAgImtleTEiOiAidmFsdWUxIiwKICAgICAgICAia2V5MiI6ICJ2YWx1ZTIiLAogICAgICAgICJrZXkzIjogInZhbHVlMyIKICAgIH0sCiAgICAidGl0bGUyIjogewogICAgICAgICJrZXkxIjogInZhbHVlMSIsCiAgICAgICAgImtleTIiOiAidmFsdWUyIiwKICAgICAgICAia2V5MyI6ICJ2YWx1ZTMiICAgICAgCiAgICB9Cn0nOwoKJGRlY29kaWZpY2FkbyA9IGpzb25fZGVjb2RlKCRqc29uKTsKCmlmICghJGRlY29kaWZpY2FkbykgewogICAgZGllKCdKU09OIGludmFsaWRvJyk7Cn0KCi8vJHRpdGxlIHBlZ2EgbyB0aXRsZTEgZSB0aXRsZTIsIHRpdGxlMywgZXRjCmZvcmVhY2ggKCRkZWNvZGlmaWNhZG8gYXMgJiR0aXRsZSkgewoJCgkvLyR2YWx1ZSBwZWdhIG8gdmFsb3Iga2V5MSwga2V5Mywga2V5Mywga2V5NCwgZXRjCglmb3JlYWNoICgkdGl0bGUgYXMgJGtleSA9PiAmJHZhbHVlKSB7CgkJCgkJLy9BcXVpIHVtIGV4ZW1wbG8gcGFyYSBhbHRlcmFyIGFzIGNoYXZlcyBjb20gbm9tZSBrZXkyIGUga2V5MyBhcGVuYXMKCQlpZiAoJGtleSA9PT0gJ2tleTInKSB7CgkJCSR2YWx1ZSA9IHJhbmQoMCwgMTAwKTsKCQl9IGVsc2VpZiAoJGtleSA9PT0gJ2tleTMnKSB7CgkJCSR2YWx1ZSA9IHJhbmQoMjAwLCAzMDApOwoJCX0KCX0KfQoKcHJpbnRfcigkZGVjb2RpZmljYWRvKTsK