问题
Hi is there a better and faster way to clean many characters from beginning of a string?
I have this one, but is this really the fastest way?
$description_new = ltrim($description_new, '###');
$description_new = ltrim($description_new, '.');
$description_new = ltrim($description_new, ',');
$description_new = ltrim($description_new, '!');
$description_new = ltrim($description_new, '?');
$description_new = ltrim($description_new, ')');
$description_new = ltrim($description_new, '(');
Thanks Nik
回答1:
the second parameter can be a charlist:
$description_new = ltrim($description_new, '#.,!?()');
You could also add a range of characters if it would suit your needs:
$clean = ltrim($binary, "\x00..\x1F");
Read about: function.ltrim
来源:https://stackoverflow.com/questions/16383965/php-ltrim-many-characters-at-once