I want to save a file as JSON, with the JSON format using PHP.
Currently I have this code, but instead of variables.txt, I want to save as variables.json, with the JSON file format, something like this:
{
ssh_user: teste,
ssh_pw: teste
}
This is my PHP code:
<?php
extract($_REQUEST);
$file=fopen("variables.txt","w");
fwrite($file,"ssh_user: ");
fwrite($file, $username ."\n");
fwrite($file,"ssh_pw: ");
fwrite($file, $password ."\n");
fclose($file);
?>
This may sound confusing, but can someone give me a tip? Thank you.