Tip: str_replace()

Here’s a quick little tip for using PHP’s str_replace() with many values. Sometimes it’s fine to just do this: $string = str_replace( ‘to_replace’, ‘replacement_string’, $string ); $string = str_replace( ‘to_replace’, ‘replacement_string’, $string ); $string = str_replace( ‘to_replace’, ‘replacement_string’, $string ); That method is fine but can get messy with many replacements. Another method is to […]