Php processing string input parameters are Maildircurusrp or Maildircurusrp. Finally, all input parameters are processed as Maildircurusrp. What are the convenient and simple methods? Thank you ------ solution javasechotrim
The input parameter is/Maildir/cur/usrp/or Maildir/cur/usrp.
Finally, it is processed as Maildir/cur/usrp.
Is there any convenient and simple method? thank you.
------ Solution --------------------
Echo trim ('/Maildir/cur/usrp /','/');
------ Solution --------------------
PHP code
$ Newstring = trim ($ string ,'/');
------ Solution --------------------
What do you mean. If it is the first character or the last character is/, remove it.
Trim functions
Echo trim ($ str, '/'); remove the '/' character at the beginning and end
------ Solution --------------------
PHP code
$ Str = "/Maildir/cur/usrp/"; $ str = substr ($ str, 0, 1) = "/"? Substr ($ str, 1): $ str; $ str = substr ($ str,-1,1) = "/"? Substr ($ str, 0,-1): $ str; echo $ str; $ str = "// Maildir/cur/usrp /////"; $ strarr = explode ("/", $ str); foreach ($ strarr as $ k => $ s) {if ($ s = "") unset ($ strarr [$ k]);} echo join ("/", $ strarr );