0

嗨,有没有更好更快的方法来清除字符串开头的许多字符?

我有这个,但这真的是最快的方法吗?

$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, '(');

谢谢尼克

4

1 回答 1

4

第二个参数可以是一个字符列表:

$description_new = ltrim($description_new, '#.,!?()');

如果适合您的需要,您还可以添加一系列字符:

$clean = ltrim($binary, "\x00..\x1F");

阅读:function.ltrim

于 2013-05-05T11:25:38.460 回答