php一次性ltrim许多字符

时间:2013-05-05 11:20:22

标签: php performance trim

您是否有更好更快的方法从字符串的开头清除多个字符?

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

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

由于 NIK

1 个答案:

答案 0 :(得分:4)

第二个参数可以是charlist:

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

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

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

阅读:function.ltrim