Reputation: 932
How can i increment x or y in this JSON file? I posted my PHP code to increment the counter, but i dont know how to acces the "infos" -> "x" or "y".
JSON file
{
"counter": 4,
"infos": {
"x": 1,
"y": 2
}
}
PHP file
<?php
$contents = file_get_contents('../test.json');
$contentsDecoded = json_decode($contents, true);
$contentsDecoded['counter']++;
$json = json_encode($contentsDecoded);
file_put_contents('../test.json', $json);
?>
Upvotes: 1
Views: 48