在PHP中,当我们执行 我想避免这种行为。 我希望领先的零点留在那里。 我该如何强制执行? p>
例如,以下代码段打印 如何强制它打印 substr() code>时,结果字符串应该是某种东西 与
0004 code>一样,PHP会自动删除前导
0 code>,只提供
4 code>。 p>
4 code> strong>。 p>
< code> echo substr(“100041”,1,4);
code> pre>
0004 code> strong>? p>
div>
In PHP when we do a substr()
such that the resultant string should be something like 0004
, PHP automatically removes the leading 0
s 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
?