Bug->Doc #54697 [Bgs->Csd]: trim function not giving right results

From: Date: Mon, 09 May 2011 18:23:35 +0000
Subject: Bug->Doc #54697 [Bgs->Csd]: trim function not giving right results
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-6378@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=54697&edit=1 ID: 54697 Updated by: philip@php.net Reported by: narjsifatima at yahoo dot com Summary: trim function not giving right results -Status: Bogus +Status: Closed -Type: Bug +Type: Documentation Problem -Package: Strings related +Package: Documentation problem Operating System: WindowsXP PHP Version: 5.3SVN-2011-05-09 (snap) -Assigned To: +Assigned To: philip Block user comment: N Private report: N Previous Comments: ------------------------------------------------------------------------ [2011-05-09 20:22:42] philip@php.net Automatic comment from SVN on behalf of philip Revision: http://svn.php.net/viewvc/?view=revision&revision=310860 Log: Clarified removing middle strings via an example and note. Deals with PHP Bug #54697 ------------------------------------------------------------------------ [2011-05-09 19:08:29] rasmus@php.net trim, as per the documentation, trims a string "from the beginning and end of a string" it doesn't replace characters in the middle of it. You probably want a str_replace here. str_replace(array('H','d','W','r'),'',$hello); ------------------------------------------------------------------------ [2011-05-09 18:37:48] narjsifatima at yahoo dot com Description: ------------ I am writing a simple function which is not giving the correct result. Please somebody check it. Test script: --------------- Here is the code. $hello = "Hello World"; $trimmed = trim($hello, "HdWr"); echo($trimmed); Expected result: ---------------- ello ol Actual result: -------------- ello Worl ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54697&edit=1

« previous php.doc.bugs (#6378) next »