You are here: Re: [PHP] Re: How to read PHP variables. « PHP « IT news, forums, messages
Re: [PHP] Re: How to read PHP variables.

Posted by Andrι Medeiros on 11/13/99 11:21

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 .= "?>";

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация