note 89750 deleted from function.trim by danbrown

From: Date: Sat, 21 Mar 2009 13:10:38 +0000
Subject: note 89750 deleted from function.trim by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152256@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- small fix for the trimString function to proof against slash and backslash: function trimString($input, $string){ $input = trim($input); $string = str_replace("\\", "\\\\", $string); $string = str_replace('/', '\\/', $string); $startPattern = "/^($string)+/i"; $endPattern = "/($string)+$/i"; return trim(preg_replace($endPattern, '', preg_replace($startPattern,'',$input))); }

« previous php.notes (#152256) next »