Jump to content

Trimming Based on String, Not Characters


drath

Recommended Posts

I have searched around for this and haven't really found anything except for the substr() function which doesn't work in this situation. Basically I want to use the trim() function to trim out a string of "ABC", yet when I use a function like this:

 

trim($file, "ABC");

 

on for example:

 

"A TEST B TEST C"

 

It will result in " TEST TEST " because it is stripping the characters rather than a full string. Does anybody know a way to do this? Thanks!

 

Link to comment
https://forums.phpfreaks.com/topic/139760-trimming-based-on-string-not-characters/
Share on other sites

Well, actually, it results in "TEST B TEST".  trim() actually just makes a character mask of the characters in the 2nd parameter and uses that to pull the left and right characters off and stuff.  What are you trying to do?  Remove a specific string from the end of a line?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.