Link to home
Start Free TrialLog in
Avatar of edyonline
edyonline

asked on

replace all variable in php using regex

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.

For example:
$_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?
Avatar of flubbard
flubbard

Possibly consider the sed command using the input as your file and outputting to a file.  Wrap this in a shell script to process the whole directory.

 - flub
SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial