<?php
function sanitize($string) {
    $list = array(
        "/dumb/",
        "/stupid/",
        "/brainless/"
    );

    # replace bad words
    $string = preg_replace_callback($list,
        function ($matches) {
            return preg_replace('/\B./', '-', $matches[0]);
        }, 
        $string);
    return $string;
}

echo sanitize('hello, i think you are not intelligent, you are actually dumb and stupid.');