Apparently there\'s no mb_trim
in the mb_* family, so I\'m trying to implement one for my own.
I recently found this regex in a comment in php.net:
mb_ereg_replace seems to get around that:
function mb_trim($str,$regex = "(^\s+)|(\s+$)/us") {
return mb_ereg_replace($regex, "", $str);
}
..but I don't know enough about regular expressions to know how you'd then add on the "charlist" parameter people would expect to be able to feed to trim() - i.e. a list of characters to trim - so have just made the regex a parameter.
It might be that you could have an array of special characters, then step through it for each character in the charlist and escape them accordingly when building the regex string.