Re: Re: How to read PHP variables.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux