ltrim strips more than needed

前端 未结 5 1125
春和景丽
春和景丽 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:14

    The second parameter species each character that will be trimmed. Because you defined both a and x the first the letters got removed from your string.

    Just do:

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

    and you should be fine.

提交回复
热议问题