我需要更改整数的格式。我知道需要应用sprintf功能,但不知道如何正确应用。如何在PHP中将数字从0到000格式化?
格式转0到000
E.g把1到001 & 19至019
我从URL获取商品代码。
$catCode=isset($_GET["cat"]) ? $_GET["cat"] : "ac";
$itemCode=isset($_GET["itemCode"]) ? $_GET["itemCode"] : "001";
foreach ($productArr[$catCode] as $imgNumber => $productDetail) {
array_push($arr, $imgNumber);
$imgNumber = $arr;
}
//count the total number of items in the array
$totalItem = count($arr);
$prevItem = ($itemCode + $totalItem - 2) % $totalItem + 1;
$nextItem = $itemCode % $totalItem + 1;
if ($itemCode > $totalItem || $itemCode < 1) {
$itemCode = 1;
}
2016-12-28
aaa