views:

40

answers:

3

I need to replace some string in a PHP code to make it look better. What would be the best way to go about that?

+5  A: 

The usual suspects would be str_replace and preg_replace.

Joey
A: 
preg_replace

Is a good way to go and uses regular expressions so you have flexibility as to how to do it.

spinon
A: 

If you want to replace a string in a lot of files once (e.g., you have something in your source code which you want to replace), sed might be the right tool for the job.

man sed
Emil Vikström