The function itself doesn't return a filtered result. To pass it from a form, you simply include this function in a viewable scope (remove the two lines from the bottom as they may generate errors), and pass in your data, probably from a $_POST['txtInput'] of some sorts. Then use like so:
if (badWordFilter($_POST['txtInput'], 1))
print 'bad words have been replaced.';
The function signature of
FUNCTION BadWordFilter(&$text, $replace)
states that the $text is run against a reference of the provided value. This is an indication that the $text is modified within the code itself, and no result needs to be returned (this returns 1 or 0 to indicate true or false for replacements, though it could return void).
Keleth has already mentioned that ereg is deprecated. This is because PHP has followed the PCRE over the POSIX compliant replacements, so you should use preg instead. This function is however bloated; there is no reason to pattern match this at all since there is no binding occurring to specific words, just to letters (it will replace in the middle of words). This can be achieved much faster and easier using str_replace instead.