PHP - 用另一个Json覆盖Json

How can i do something like this? Does someone know how to get content from another Json file and overwrite another json file with new value. I tried this but no result. Can someone help me with this, i need this its an commission from school.

the two Json files are list.json and listbackup.json. I want a code that can use listbackup.json file to overwrite list.json.

 $backupFile= file_get_contents("listbackup.json");
        $backupFile= json_encode($backupFile, "
");
        file_put_contents('list.json', $backupFile);

If the file is already json you dont need to use json_encode.

Make a backup

$listFile = file_get_contents("list.json");
file_put_contents('listbackup.json', $listFile);

Restore a backup

$backupFile = file_get_contents("listbackup.json");
file_put_contents('list.json', $backupFile);
$backupFile = file_get_contents("listbackup.json");
$backUpJsonDecoded = json_decode( $backupFile );

// do changes
$backupJsonDecoded->option->value = 'different';

$newFileContents = json_encode( $backupJsonDecoded );
file_put_contents( 'list.json, $newFileContents );