Hello my Success-Oriented Friends,
Firstly, how do i code my MT_RAND() command to generate just 4 digit numbers for my PIN and confirmation.
Secondly, how do i make the number entered into one of the fields in my form to appear as currency. I want dot (.) to com after the first two digits and comma(,) after every 3 digits for it to look like this (1,234,567.89)
Regards
adsegzy
generating 4 digit figures adding comma(), & dot (.)
Moderator: General Moderators
Re: generating 4 digit figures adding comma(), & dot (.)
You could use the php rand function to generate a random 4 digit number
This Function won't give you numbers less than 1000 like 0001, 0010 etc you could do a rand 0 to 9999 and then add leading 0's when required
The PHP function number_format will format your numbers with your commas and decimal place or you might want to have a look at money_format but i always prefer number_format
Code: Select all
$MyRandomNumber = rand(1000,9999);
The PHP function number_format will format your numbers with your commas and decimal place or you might want to have a look at money_format but i always prefer number_format