allex01 Posted February 18, 2008 Share Posted February 18, 2008 I have a file that contains all types of constants that looks like this $CFG['admin']['value']['article_value'] = '9'; $CFG['admin']['value']['article_upload_value'] = '10'; $CFG['admin']['value']['game_comment_value'] = '11'; I created a form with input fields where a user can input and change the values for article_value, article_upload_value, game_comment_value. My question is , how can i make those values replace the current values in the constant file when the submit button is hit. You don't have to work with my current scheme. A simple example on how to update constants in a file would be helpfull. Quote Link to comment Share on other sites More sharing options...
trq Posted February 18, 2008 Share Posted February 18, 2008 They are not constants, but simple array values. As for writting to a file, take a look at fwrite(). Quote Link to comment Share on other sites More sharing options...
allex01 Posted February 18, 2008 Author Share Posted February 18, 2008 Yes you're write. How can i write to the array values using a form with input fields. I dont' get how to use fwrite to replace the value only. Quote Link to comment Share on other sites More sharing options...
trq Posted February 18, 2008 Share Posted February 18, 2008 Do i still need to use fwrite() If you want to actually overwrite the values in the file. If you just want them temporarley overiden you would use something like.... <?php if (isset($_POST['submit'])) { $CFG['admin']['value']['article_value'] = $_POST['admin_value_article_value']; $CFG['admin']['value']['article_upload_value'] = $_POST['admin_value_article_upload_value']; $CFG['admin']['value']['game_comment_value'] = $_POST['admin_value_game_comment_value']; } ?> Quote Link to comment Share on other sites More sharing options...
allex01 Posted February 18, 2008 Author Share Posted February 18, 2008 Thank you Thorpe. I was looking for a permanent overwrite and not temporary. Quote Link to comment Share on other sites More sharing options...
allex01 Posted February 18, 2008 Author Share Posted February 18, 2008 On further support on this would be appreciated. I just need guidance in the right direction. Quote Link to comment Share on other sites More sharing options...
trq Posted February 18, 2008 Share Posted February 18, 2008 Did you take a look at fwrite()? Quote Link to comment Share on other sites More sharing options...
allex01 Posted February 18, 2008 Author Share Posted February 18, 2008 Sure, i did. fwrite() writes to a file but my question was how to make it write to a specific array value in the file mentioned above I'm assuming the general funcitonality of fwrite only writes at the end of a text file by default correct?.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.