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

From: Date: Mon, 09 May 2011 17:08:29 +0000
Subject: Bug #54697 [Opn->Bgs]: trim function not giving right results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-160625@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:         rasmus@php.net
 Reported by:        narjsifatima at yahoo dot com
 Summary:            trim function not giving right results
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            Strings related
 Operating System:   WindowsXP
 PHP Version:        5.3SVN-2011-05-09 (snap)
 Block user comment: N
 Private report:     N

 New Comment:

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);


Previous Comments:
------------------------------------------------------------------------
[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


Thread (2 messages)

« previous php.bugs (#160625) next »