|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-05-09 18:37 UTC] 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 19:00:01 2025 UTC |
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);