note 89207 added to function.trim

From: Date: Thu, 26 Feb 2009 14:23:47 +0000
Subject: note 89207 added to function.trim
Groups: php.notes 
Request: Send a blank email to php-notes+get-151165@lists.php.net to get a copy of this message
If what you need is delete a string instead of character, this function could helps you: function trimString($input, $string){ $input = trim($input); $startPattern = "/^($string)+/i"; $endPattern = "/($string)+$/i"; return trim(preg_replace($endPattern, '', preg_replace($startPattern,'',$input))); } Use: echo trimString(" Hello world!. I said hello", "hello") Will return: world!. I said ---- Server IP: 80.64.47.13 Probable Submitter: 213.60.65.196 ---- Manual Page -- http://www.php.net/manual/en/function.trim.php Edit -- https://master.php.net/note/edit/89207 Del: integrated -- https://master.php.net/note/delete/89207/integrated Del: useless -- https://master.php.net/note/delete/89207/useless Del: bad code -- https://master.php.net/note/delete/89207/bad+code Del: spam -- https://master.php.net/note/delete/89207/spam Del: non-english -- https://master.php.net/note/delete/89207/non-english Del: in docs -- https://master.php.net/note/delete/89207/in+docs Del: other reasons-- https://master.php.net/note/delete/89207 Reject -- https://master.php.net/note/reject/89207 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#151165) next »