Смена данных в json в foreach
Я пытаюсь сделать так чтобы в json менялось значение
<form method="POST">
<?php
$json2323232 = file_get_contents('avatar/'.$_COOKIE['accname'].'.json');
$data2323232 = json_decode($json2323232, true);
$json232323245 = file_get_contents('accounts/'.$_COOKIE['accname'].'.json');
$data232323245 = json_decode($json232323245, true);
foreach($data2323232 as $element1){
if(isset($_POST[$element1])){
$data232323245['Avatar'] = $element1;
$newJsonString = json_encode($data232323245);
file_put_contents('accounts/'.$_COOKIE['accname'].'.json', $newJsonString);
}
echo '<input value="'.$element1.'" style="background-image:url(http://test.parodyiu.beget.tech/'.$element1.');" type="submit" name="'.$element1.'"><br>';
}
?>
</form>
Но ничего не происходит, не могу понять почему