vikrantmohite Posted June 6, 2012 Share Posted June 6, 2012 Hi, I want to generate a 10 digit PNR number in one of my application. The PNR number to be generated should use the following : 1. The name of the passenger(s). 2. Contact details for the travel agent or airline office. (The minimum contact information enforced by CRS policy is typically the 8-digit IATA code of the travel agency or airline office, although there is usually at least one phone number as well, most often the agency phone number. Direct customer contact information is rarely required.) 3. Ticketing details, either a ticket number or a ticketing time limit. 4. Itinerary of at least one segment, which must be the same for all passengers listed. 5. Name of the person providing the information. (This is usually entered in a "received from" field and recorded in the "history" or change log attached to the PNR, along with the user and office or agency ID of the airline or travel agency employee creating the PNR or entering the change. The "history" records the "received from" data separately for the initial creation of the PNR and for each subsequent change to it.) For better understanding of PNR follow http://en.wikipedia.org/wiki/Passenger_name_record I was planning to do MD5() on all the above fields but that will give me more than 10 letters(alphanumeric) Though it is mention in wiki that PNR can be Alphanumeric, I want to generate a Numeric PNR. Please help me on this. Regards, Vikrant Quote Link to comment https://forums.phpfreaks.com/topic/263743-pnr-number/ Share on other sites More sharing options...
Kieran Menor Posted June 6, 2012 Share Posted June 6, 2012 Well, you could just crop the MD5 hash to the desired length. Example: $forty_bits = substr($md5_hash, 0, 10); // 40 bits (10 hex digits of 4 bits each) is enough for a 10 digit decimal number $decimal = base_convert($forty_bits, 16, 10); // Convert from hexadecimal (base 16) to decimal $ten_digits = substr($decimal, 0, 10); $padded_result = str_pad($ten_digits, 10, '0', STR_PAD_LEFT); // Pad the resulting number to 10 digits, just in case Quote Link to comment https://forums.phpfreaks.com/topic/263743-pnr-number/#findComment-1351575 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.