Using a random number to be included with another character. Then I want to strip out the random number and just leave the other character. I have this code that generates the random number (8 characters long) consistently. If you hit your refresh button multiple times, the “ID” field disappears even though the “Random Number” plus “ID” are still there. Not sure what is happening to the random number on refresh in the substr function.
This is the code:
// Begin Create Random ID Code /////////////////////////////////////////
function gRanStr1() {
$length1 = 8;
$characters = “0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”;
for ($p = 0; $p < $length1; $p++) {
$lcrs1 .= $characters[mt_rand(0, strlen($characters)-1)];
}
$lcrs9 = str_replace(' ', '', $lcrs9);
return $lcrs1;
}
// End Create Random ID Code /////////////////////////////////////////
// Begin Decode Random ID Code /////////////////////////////////////////
$TrkR99 = "c";
$ResHeadID = gRanStr1() . $TrkR99;
$ResHeadID = preg_replace('/[\s]+/',' ',$ResHeadID);
echo "”;
echo $ResHeadID . ” = echo of Random Number plus ID“;
for($i=0; $i
if ($ResHeadID == "") {
"";
} else {
$ResHeadID = preg_replace('/[\s]+/',' ',$ResHeadID);
$TrkRa1 = substr($ResHeadID, $Index1 + 8, 1);
}
$dTrkRes = $TrkRa1;
echo $TrkRa1 . " = echo of ID after random number stripped.“;
echo “”;
// End Decode Random ID Code /////////////////////////////////////////