2015-06-03 14:49
浏览 37

ltrim函数不能按预期工作? PHP

I am using ltrim function. I run this code :

echo ltrim("looooooooooooooooooooooooongWord","long");

i expect to get this word : looooooooooooooooooooooooongWord but it prints Word.

what's the problem ?

Edit: I thought it remove the word long, but it appears it remove the l,o,n,g characters !

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duancongjue9202
    duancongjue9202 2015-06-03 14:50

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

    It does exactly as it says, strips chars l, o, n, g.

    点赞 评论
  • duannaoben8011
    duannaoben8011 2015-06-03 14:50

    From the docs: (please read them).

    string ltrim ( string $str [, string $character_mask ] )


    The input string.


    You can also specify the characters you want to strip, by means of the character_mask parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters.

    点赞 评论