<?php

function pr($array_to_output)
{
    print '<pre>';
    print_r($array_to_output);
    print '</pre>';
}

//
// Written by Patrick Rauchfuss
class String
{
    public static function stritr(&$string, $from, $to = NULL)
    {
        if(is_string($from))
            $string = preg_replace("'/\b$from\b/'i", $to, $string);

        else if(is_array($from))
        {
            foreach ($from as $key => $val)
                self::stritr($string, $key, $val);
        }

        return $string;
    }
}


$wordsTransform = array(
            'shit' => 'ship'
        );

$string = "Rolling In The Deep\n
\n
There's a fire starting in my heart\n
Reaching a fever pitch, and it's bringing me out the dark\n
Finally I can see you crystal clear\n
Go ahead and sell me out and I'll lay your SHIT bare";

$string = strtr($string, $wordsTransform);

pr(String::stritr($string, $wordsTransform));
