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 !

图片转代码服务由CSDN问答提供 功能建议

我正在使用 ltrim 函数。 运行此代码:

  echo ltrim(”looooooooooooooooooooooooongWord“,”long“); 
 <  / code>  

我希望得到这个词: looooooooooooooooooooooooongWord 但它打印 Word < 问题是什么?

编辑: 我认为它删除了单词long,但它似乎删除了l,o,n,g字符!

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

2条回答 默认 最新

  • 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 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.

    打赏 评论

相关推荐 更多相似问题