- rtrim: documentation ( source)
- htmlentities: documentation ( source)
- preg_replace: documentation ( source)
- strtolower: documentation ( source)
<?php
$input = "Wij #^@ & zij !> !-?!";
echo rtrim(preg_replace('/([^a-z0-9]+)/', '-', strtolower(preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities($input)))), '-');