Welcome Guest, Not a member yet? Register   Sign In
[CodeIgniter] changing config.php by code
#4

[eluser]BrianDHall[/eluser]
Ah what the hell, one more regex for the day:

Code:
// $file should contain full text of config.php

$key = 'index_page';
$new_value = '';

$search = '(\$config\[' . "'" . $key . "'" . '\] =)([^;])';
$replace = '\1"' . $new_value . '"';

$file = preg_replace("/$search/", $replace, $file);

Untested, but I think it should just about do it.

So $key is whatever config item you want to change the value of, and $new_value is what you want to set it to. And then that's it.

It's a place for you to start at least Smile


Messages In This Thread
[CodeIgniter] changing config.php by code - by El Forum - 11-12-2009, 02:26 PM
[CodeIgniter] changing config.php by code - by El Forum - 11-12-2009, 02:35 PM
[CodeIgniter] changing config.php by code - by El Forum - 11-12-2009, 02:48 PM
[CodeIgniter] changing config.php by code - by El Forum - 11-12-2009, 03:03 PM
[CodeIgniter] changing config.php by code - by El Forum - 11-12-2009, 03:18 PM
[CodeIgniter] changing config.php by code - by El Forum - 11-12-2009, 03:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB