PHP - strip all non alphanumeric characters from a string

A PHP function that strips a string of all characters other than alphanumeric characters:

function onlyAlphanumericAndSpaces($text) {
  # allow only alphanumeric
  return ereg_replace("[^A-Za-z0-9 ]", "", $text );
}