note 89751 deleted from function.trim by hholzgra

From: Date: Thu, 02 Aug 2012 12:29:41 +0000
Subject: note 89751 deleted from function.trim by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189665@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: <?php 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 (#189665) next »