I need to be able to permanently change variables in a php file using php. 

I am creating a multilanguage site using codeigniter and using the language helper which stores the text in php files in variables in this format: 
`$lang['title'] = "Stuff";`

I've been able to access the plain text of the files using fopen() etc and I it seems that I could probably locate the areas I want to edit with with regular expressions and rewrite the file once I've made the changes but it seems a bit hacky.

Is there any easy way to edit these variables permanently using php?

Cheers