ltrim strips more than needed

前端 未结 5 1123
春和景丽
春和景丽 2021-01-25 01:36

Is there a way to limit exactly what ltrim removes in PHP.

I had a the following outcome:

$str = \"axxMyString\";
$newStr = ltrim($str, \"ax\");
// resu         


        
5条回答
  •  情歌与酒
    2021-01-25 02:30

    ltrim() manual:

    Strip whitespace (or other characters) from the beginning of a string.

    So...

    $newStr = ltrim($str, "ax");
    

    This will remove every character 'a' and 'x' at the beginning of string $str.

    Use substr() to get part of string you need.

提交回复
热议问题