3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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"), '', $string); var_dump($array);
based on eqv00
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(6) { [0]=> string(5) "ABCDE" [1]=> string(5) "ABCDE" [2]=> string(5) "ABCDE" [3]=> string(5) "ABCDE" [4]=> string(7) "ABCDE " [5]=> string(7) "ABCDE " }