Here's my code:
$user = new User($_POST['login'], $_POST['password'], $_POST['mail'], $_POST['name']);
$users = json_decode(file_get_contents('users.json'));
$users[] = $user->toArray();
file_put_contents('users.json', json_encode($users));
When the json file is empty, user gets added correctly, but when a user already exists in json file, when I try to add another user using this code, it just replaces the existing user.
print_r($users)please when there is something in $users