What about...

<form action="saveConfig.php" method="post">

Database Host: <input type="text" name="config[database][host]"
value="<?=$config['database']['host']?>" /><br />
Database User: <input type="text" name="config[database][user]"
value="<?=$config['database']['user']?>" /><br />

<!-- some more fields here -->

</form>

And then...

<?php
$newConfigValues = $_POST['config'];

$fileCode = "<?php\n// AUTOMATICLLY CREATED CONFIG FILE. DO NOT EDIT!
\n";
foreach( $newConfigValues as $parentConfigKey => $parentConfigValue ) {
        if( is_array( $parentConfigValue ) {
                foreach( $parentConfigValue as $childConfigKey => 
$childConfigValue )
{

                        $fileCode .= 
"$config['$parentConfigKey']['$childConfigKey'] =
'$childConfigValue';\n";

                }
        }
        else {
                $fileCode .= "$config['$parentConfigKey'] = 
'$parentConfigValue'\n";
        }
}

$fileCode .= "?>";

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to