0
Dear Devs, I’m trying to use a list with zero left using for and str_pad, but I’m not getting the variable with 0 left, the first variable comes complete but in the autoincrement it’s counting without the digits, could you help? The code is currently as follows:
<?php
for($x = str_pad(1, 4, 0, STR_PAD_LEFT); $x < str_pad(1000, 4, 0, STR_PAD_LEFT); ++$x) {
echo "O X é: ".$x."<br/>";}
It’s very confusing. PHP doesn’t have auto increment, so it’s involving databases, but the question doesn’t talk about it at all. Auto increment is number, so there’s no point in having zeros on the left. If you want to do other things you need to specify in detail, it’s probably not even to do what you want. Or it is, but the context is another.
– Maniero