How can PHP be used to convert a string like "Recht für Kinder?" into "recht_fuer_kinder.txt"?

To convert a string like "Recht für Kinder?" into "recht_fuer_kinder.txt" in PHP, we need to first remove any special characters, convert the string to lowercase, replace spaces with underscores, and append ".txt" at the end. This can be achieved by using functions like strtolower(), preg_replace(), and pathinfo().

$string = "Recht für Kinder?";
$filename = strtolower(preg_replace('/[^a-z0-9]+/', '_', pathinfo($string, PATHINFO_FILENAME))) . ".txt";
echo $filename;