![]() |
Small help with regex code - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Small help with regex code (/showthread.php?tid=28307) |
Small help with regex code - El Forum - 03-07-2010 [eluser]sunnyd[/eluser] Hi all, I have a config file which looks like so: $GLOBALS['dbname'] = 'test'; $GLOBALS['dbuser'] = 'test1'; $GLOBALS['dbpass'] = 'test2'; Is there a regex function that I can use to properly extract for example dbname and its value and save that into a separate variables. At the moment, this is the code that I am trying to use: Code: $file_handle = fopen($myfile, 'r'); So far, if i try $config['dbname'], the value is empty. Am I doing something wrong? Small help with regex code - El Forum - 03-08-2010 [eluser]Christopher Blankenship[/eluser] Is there a particular reason you must use regex for this or could you do the following: For your code block: Code: <?php myconfig.php Code: <?php Small help with regex code - El Forum - 03-08-2010 [eluser]Christopher Blankenship[/eluser] And here would be away to fix the code so it would work. Code: <?php globals.php Code: <?php This would output the following: Array ( [dbname] => test [dbuser] => test1 [dbpass] => test2 ) |