Today, when dealing with a specific character at both ends of the string, you encounter the following problem, first look at the example
<span style= "font-size:18px" ></SPAN>
$str = ' Akmumu/writedb.json ';
What I'm going to do is delete the starting Akmumu, and then delete the. JSON at the end, so that only useful characters are preserved/writedb
Start the LTrim I use to remove Akmumu, and then use RTrim to remove it. JSON
It turns out that I understand the trim error, and the trim parameters are as follows
RTrim (String,charlist)
His arguments are charlist, which is not necessarily in order, like I give a
$str = ' Akmumu/writedbsojn.json ';
The result is still/write, I want the/WRITEDBSOJN did not appear, that is, as long as the charlist of any character matching is always so down ...
So I used something else.
Str_replace,substr_replace can
For security reasons, add code to prevent further interception of errors
Copy Code code as follows:
if (Strpos ($str, ' akmumu/')!== FALSE
$str = substr ($str, 7);
if (Strpos ($str, '. JSON ')!== FALSE)
{
if (substr ($str, -5,5) = = '. JSON ')
{
$str = Substr_replace ($str, ',-5);
}
}
}
That's it, okay?