PHP to save file with JSON format

one text

Solution:

file_put_contents('variables.json', json_encode([
    'ssh_user' => $_REQUEST['username'] ?? null,
    'ssh_pw'   => $_REQUEST['password'] ?? null,
]));

Please note that your code extract($_REQUEST) can have security implications.

Source