- substr: documentation ( source)
- mt_rand: documentation ( source)
<?php
class Tracking {
function __construct($client) {}
function generateID($length) {
$id = $client;
$x = 0;
while ($x < $length) {
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789';
$id .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
return $id;
}
}
$parcel = new Tracking(1426);
echo $parcel->generateID(20);