dsfds656545 2018-09-02 14:13 采纳率: 0%
浏览 111
已采纳

如何通过PHP substr()函数覆盖/更改前导零的默认删除? [关闭]

In PHP when we do a substr() such that the resultant string should be something like 0004, PHP automatically removes the leading 0s and just gives 4.

I want to avoid this behavior. I want the leading zeroes to stay there. How can I enforce that?

Forexample the following snippet prints 4.

echo substr("100041", 1, 4); 

How can I force it to print 0004?

  • 写回答

3条回答 默认 最新

  • donglin6313 2018-09-02 14:20
    关注

    Who said? Php doesn't remove 0 in string...

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?