function str_trim( $text )
{
$text = str_replace( array( "\r\n", "\r", "\n", "\t", " " ), " ", $text );
$text = explode( " ", $text );
for( $i = 0;$i <= count( $text );$i++ ) {
$str[] = trim( $text[$i] );
}
$str = implode( " ", $str );
return $str;
}