简体   繁体   中英

Generate unique Device Id using php

Hello friends i want to generate device Id using PHP ( FINTECH_XXXX.10/11/2020.1000001) For each device 1000001 increases by +1 and date changes on daily basis.

Please help!!

try this

$deviceIds = [];
$initNumber = 1000001;
for ($i = 1; $i <= 10; $i++) {
    $date = date('d/m/Y');
    $deviceId = "FINTECH_XXXX.$date.$initNumber";
    array_push($deviceIds, $deviceId);
    $initNumber++;
}
print("<pre>");
print_r($deviceIds);

this will output

[
"FINTECH_XXXX.19/11/2020.1000001",
"FINTECH_XXXX.19/11/2020.1000002",
"FINTECH_XXXX.19/11/2020.1000003",
"FINTECH_XXXX.19/11/2020.1000004",
"FINTECH_XXXX.19/11/2020.1000005",
"FINTECH_XXXX.19/11/2020.1000006",
"FINTECH_XXXX.19/11/2020.1000007",
"FINTECH_XXXX.19/11/2020.1000008",
"FINTECH_XXXX.19/11/2020.1000009",
"FINTECH_XXXX.19/11/2020.1000010"
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM