3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "ABCDE "; $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", "\f", "\0"), '', $string); var_dump($array);

preferences:
40.45 ms | 402 KiB | 5 Q