I am using a configuration file for something I am working on. In that configuration file, I have a line like $twelveHourTimeEnabled = true;
. I want to be able to switch true to false in this but am not sure the way to change just that line from true
to false
.
Currently, I am using separate files that switches the two, but I know this must be grossly inefficient.
$fn = "config.php";
$file = fopen($fn, "w+");
$size = filesize($fn);
$twelveHourConfig = "12hrconfig.php";
$twelveHourConfigFile = file_get_contents($twelveHourConfig);
fwrite($file, $twelveHourConfigFile);
fclose($file);
How would I switch the true value to false, or vice versa without requiring two other files to read in?
EDIT:
This project is a PHP plug-in for a desktop app (Alfred App for Mac OS X) which returns TV information to the user wherever they are. For this reason, this action is being done when a keyword is called. For this reason there is no way to use a database, etc.
EDIT 2: Sorry, I have no experience with JSON or other file IO operations as I normally deal with CRUD. Also, know that I have no control over the user machines, etc. This needs to function with PHP that would be installed by default when someone installs Mac OS X. Nothing more. If someone can explain JSON I would be happy to use it, I just don't know anything about it, how to use it, etc.