3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['Ù', 'é', '€']; $string = "é & Ù @ ♣ ☂ % & € À"; $acceptedChars = implode('', $arr); $string = preg_replace('/[^ -~' . $acceptedChars . ']/u', '', $string); echo 'Test : ' . $string;

preferences:
53.79 ms | 402 KiB | 5 Q