I'm bringing DB data that will be used as Values
of Keys
of my new file.json
that I'm trying to create. The Keys
is being read from an existing JSON file.
So, basically what I need to do is an existing file, but with different values. The format looks something like this:
//Abro arquivo já existente
$myFile = fopen($fileName, "r") or die("Unable to open the file !");
//Content possui o conteúdo do meu arquivo
$content = json_decode(fread($myFile, filesize($fileName)));
fclose($myFile); //Fecha arquivo
foreach( $content as $keys => $value ) {
foreach( $value as $key) {
//....
}
}
The format looks something like this:
{
"title1": {
"key1": "value1",
"key2": "value2",
"key3": "value3"
},
"title2": {
"key1": "value1",
"key2": "value2",
"key3": "value3"
},
}
With the loop shown above, I can already scroll through all Keys
of each Title
(I do not know correct name).
I would like help with logic to build the new file with what I have now.