Arne-Christian 0 Report post Posted November 19, 2006 Ok lets say i have a config.php file, i want to edit something without open it, i know every line number and that, now how would i do this?I will show you a example: <?php$CONFIG['user'] = 'root';$CONFIG['server'] = 'localhost';$CONFIG['pass'] = '******';$CONFIG['db'] = '******';$CONFIG['install'] = '1';$CONFIG['lang'] = 'en';?> Now lets say i want to change $CONFIG['lang'], HOW would i do this without open the file?Thanks Share this post Link to post Share on other sites
truefusion 3 Report post Posted November 19, 2006 Technically, the file is gonna be opened anyways, by the script, for reading and writing. Though, i think it's best not to change permissions to the file.However, this is how i'd go about it. I'd use file_get_contents() to place everything in a variable. Then, use some kind of replacement function, to search for "$CONFIG['lang'] = 'en';", using some kind of regex, and replace whatever is the value. Then just overwrite the content of the file with the variable. But i don't know how good this will work. So, back up any files before testing. Share this post Link to post Share on other sites
farsiscript 0 Report post Posted November 20, 2006 hi dear Arne-Christian Your are talking about value in php , its like smarty engine for template or change languche how we can use this ?for example we want make one script we n lan ! how ?How to include this File and value ? Share this post Link to post Share on other sites
Arne-Christian 0 Report post Posted November 20, 2006 Uh, i am talking about variables and writing into files on specific places..., is it that hard to understand, When shall you get it into your head that i know more then the basics?Anyways i will try truefusions idea. Share this post Link to post Share on other sites