php - Generating a random number complying a specific pattern -


I want to generate a number that contains 14 digits but I want to generate it in a certain method. Consider the following number:

292 0505 150 0253

  • Bold numbers Constants are
  • 0505 one day and one month meaning 05 the month and 05 is the day. Therefore, while generating a random number, the first part should be from 0 to 12 and second to 1 to 31 Li>
  • The other number ( 150 ) is random

I want curl after every attempt for a page.

function randomNumber ($ startDate, $ endDate) {$ day = round (strtotime ( $ EndDate) - strtotime ($ startdate)) / (60 * 60 * 24)); $ N = Rand (0, $ day); Return '292'Det ("MD", stronteme ("$ startdate + $ n days")) Rand (100,999).' 0253 '; } $ MyRandomNumber = Random Number ('2010-01-01', '2010-12-31'); $ Url = "http://www.example.com"; $ Ch = curl_init (); Curl_setopt ($ CH, CURLOPT_POSTFIELDS, $ myRandomNumber); Curl_setopt ($ CH, CURLOPT_POST, 1); Curl_setopt ($ CH, CURLOPT_TIMEOUT, 10); Curl_setopt ($ CH, CURLOPT_FOLLOWLOCATION, true); Curl_setopt ($ ch, CURLOPT_URL, $ url); Curl_setopt ($ CH, CURLOPT_RETURNTRANSFER, true); $ Response = curl_exec ($ ch);

It is assuming that you are posting data. If GET (or other HTTP method) is to be used then the change will be required.

You can give a date range that you want to include for the first 4 random numbers (for example, to allow leap year to include / leave - or date before today To keep)


Comments