How to make the editor config?

Good evening, help to make the editor config,
there is a file conf.php
it has a code and a string
$config = ['user' => 'admin','name' => 'GOD','pass' => '123123'];

I want to make all the data from $config loaded in a line and each in your input for convenient edition I need so I can edit the line $config without changing the other code in this file, this is not difficult distribute an example or throw off the link where you can take and then he will understand
March 23rd 20 at 19:07
2 answers
March 23rd 20 at 19:09
Write down the config as an array to a file, attach the file and assign a variable in code, use an array and the keys
File Conf
return ['user' => 'admin','name' => 'GOD','pass' => '123123'];

Where necessary
$conf = require('conf.conf');
echo $conf['user'];

// save
file_put_contents('conf.conf', "<?php\n\n" . 'return' . var_export($config, true) . ";\n");
March 23rd 20 at 19:11
Something in the spirit:
// the config polecenie
$config = require 'my_config.php' // in the file return ['user' => 'admin','name' => 'GOD','pass' => '123123']

// display the form for editing
foreach ($config as $name => $value) {
 echo "<input name=$name value=$value>"

// save
$fileData = "
foreach ($_POST as $name => $value) {
 $fileData .= "'$name' => '$value'"
if ($fileData) {
 file_put_contents(my_config.php "return [$fileData]")
The array curve will be - Marcellus.Turcot commented on March 23rd 20 at 19:14

Find more questions by tags PHP