trim() not working according to php.net site examples

From: Date: Fri, 14 Mar 2003 01:03:42 +0000
Subject: trim() not working according to php.net site examples
Groups: php.general 
Request: Send a blank email to php-general+get-139631@lists.php.net to get a copy of this message
The below does not remove the control characters as the site examples show. I was doing it to the $HTTP_POST_VARS, with a whole lot more functionality, but I can't ANY thing to modify the string below ........ :-( Anyone got any ideas why this does not print a string trimmed of all the \t,\r,\n characters? (And I haven't even begun to deal with the 'reference' issues) ======================================================================================== <?php echo("<pre>\n"); function clean_gpc( &$x ) { echo("<br>\nIN FUNCTION--------------------------------------------------------------------"); echo( trim($x,"\x00..\x20") . "<br>\n" ); // supposedly trims all control codes and spaces from ends of string echo("<br>\nOUT FUNCTION--------------------------------------------------------------------"); } $bad_str = " \t\t\t\\r\\\r\r\r\r\n\r\nFour schore ...........and seven \n\n\n\n\nr\r\r\rn\r years ago, ,,,,,,, ,,,,,,,our father created on tis planet \t\t\t\\r\\\r \r\r\r\n\r\nFour "; echo("<pre>\n"); clean_gpc( $bad_str ); echo("</pre>\n"); ?>

« previous php.general (#139631) next »