3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sanitize($value) { $special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}"); $value = utf8_encode($value); $value = str_replace($special_chars, '', $value); $value = preg_replace('/[\s-]+/', '-', $value); $value = trim($value, '.-_'); return $value; } echo sanitize("hola como estas");

preferences:
46.41 ms | 402 KiB | 5 Q