3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "ABCDE \t\n\r\x0B\x0C\0\x20\x0e\x20\x0f"; $array = array(); $array[] = trim($string); $array[] = preg_replace('/\s+/', '', $string); $array[] = preg_replace('/\s\s+/', '', $string); $array[] = trim(preg_replace('/[\s\t\n\r\s]+/', '', $string)); $array[] = preg_replace('/~\x{00a0}~siu/', '', $string); $array[] = str_replace(array(" ", "\t", "\n", "\r", "\x0B", "\x0C", "\0", "\x20\x0e", "\x20\x0f"), '', $string); var_dump($array);

preferences:
33.96 ms | 402 KiB | 5 Q