Cenron Posted June 16, 2007 Share Posted June 16, 2007 Hey guys I have a php file that looks like this <?php /* load="1" menu_item="General" menu_url="general.php" */ ?> Now my question is, I want to use that as a set of general configuration so I want to be able to read the file find for example load and read the value thats assigned to it so like something like this load="1" $should_be_loaded = read_file_and parse("load"); that would return 1; any ideas guys. Hope i explained it well enough. Quote Link to comment https://forums.phpfreaks.com/topic/55853-solved-string-manipulation-help/ Share on other sites More sharing options...
Rojay Posted June 16, 2007 Share Posted June 16, 2007 thats easy the firs file should look like this $load = 1; $menu_item="General" then in the other file use include("file_path"); Quote Link to comment https://forums.phpfreaks.com/topic/55853-solved-string-manipulation-help/#findComment-275941 Share on other sites More sharing options...
Cenron Posted June 16, 2007 Author Share Posted June 16, 2007 ya but theres other stuff in that file that goes on that I really dont want included like that....cause all those are just switches that people can turn on or off to keep the file from being loaded as a module. Quote Link to comment https://forums.phpfreaks.com/topic/55853-solved-string-manipulation-help/#findComment-275949 Share on other sites More sharing options...
Rojay Posted June 16, 2007 Share Posted June 16, 2007 well you can put them in XML format and use SimpleXML to load them http://www.php.net/manual/en/ref.simplexml.php Quote Link to comment https://forums.phpfreaks.com/topic/55853-solved-string-manipulation-help/#findComment-275954 Share on other sites More sharing options...
Barand Posted June 16, 2007 Share Posted June 16, 2007 That's pretty much an ini file format if you lose the quotes <?php $config = parse_ini_file('myfile.txt'); echo $config['menu_url']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/55853-solved-string-manipulation-help/#findComment-275977 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.