replace all variable in php using regex
Posted on 2011-02-11
I have a lot of php files and in order to standardize the coding structure, I need to make all array variable to be 'more' valid by adding quote in between.
$_POST[variablename] replaced to $_POST['variablename']
$_SESSION[variablename1][variablename2] replaced to $_SESSION['variablename1']['variablename2']
$_GET['variablename'] is to be skipped and do nothing because it's in good format
Now, I know I can use perl or awk to go over all files and using regex to insert the quote. What's the quickest way to achieve this and how do I do it?