PHP Write bulk generate non-duplicated card number password Code _php tutorial

Source: Internet
Author: User

PHP Write bulk generate non-duplicated card number password code


This article to share is a very practical code, the project often need to use, you can batch generation of the card number of the password 2 methods, the need for small partners to refer to it.

When the pain of the egg, by the way to strengthen their own in the PHP array manipulation of some skills, wrote the following a small code, you can randomly generate the corresponding array of card number password, and automatically to repeat, the idea is not, purely nonsense.

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21st

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

function Makecard ()

{

Set_time_limit (0);

Handling buffers

Ob_end_clean ();

Ob_implicit_flush (TRUE);

echo Str_pad ("", 256);

if (intval ($_post[' num ']>0)) $num =intval ($_post[' num ']); Number

if (intval ($_post[' point ']>0)) $point =intval ($_post[' point '); Points

if (Intval ($_post[' batch ']>0)) $batch =intval ($_post[' batch ']); Batch

if (($_post[' ym ']!= ")) $ym =$_post[' ym ']; Issue date

else $ym =date (' ym ');

if ($num ==0) return;

$num = $num *100; Number of cards, i.e. number of records

echo "

Start ". Date (" H:i:s ")." ";

for ($i =1; $i <= $num; $i + +)

{

$SN =sprintf ("%02s%s%06s", $batch, $ym, $i);

$seek =mt_rand (0,9999). Mt_rand (0,9999). Mt_rand (0,9999); 12 Guests

$start =mt_rand (0,20);

$str =strtoupper (substr (MD5 ($seek), $start, 12));

$str =str_replace ("O", Chr (Mt_rand (65,78)), $STR);

$str =str_replace ("0", Chr (Mt_rand (65,78)), $STR);

$row =array (' sn ' = = $sn, ' password ' + $str, ' created ' =>time (), ' point ' = = $point);

Duplicate checking

Add the code to insert the data here.

Print_r ($row);

}

echo "End". Date ("H:i:s"). "";

printf ("
Successful build: Password for%s million%s points

", $num/1e4, $point);

return $num;

}//Function end

$_post[' num ']=1;

$_post[' point ']=10;

$_post[' Batch ']=10;

$_post[' ym ']= ' 1405 ';

Echo Makecard ();?>

Method Two:

?

1

2

3

4

5

6

7

8

9

11

+

+

/+

/

/+

/

+

+

+

!--? php

$numLen =16;

$pwdLen =10;

$c =100;//Generate 100 Group card number password

$sNumArr =range (0,9);

$sPwdArr =array_merge ($SNUMARR, Range (' A ', ' Z '));

$cards =array ();

for ($x =0; $x < $c; $x + +) {

$tempNumStr =array ();

for ($i =0; $i < $numLen; $i + +) {

$tempNumStr []=array_rand ($SNUMARR);

}

$tempPwdStr =array ();

for ($i =0; $i < $pwdLen; $i + +) {

$tempPwdStr []= $sPwdArr [Array_rand ($SPWDARR)];

}

$cards [$x] [' No ']=implode (', $tempNumStr);

$cards [$x] [' pwd ']=implode (', $tempPwdStr);

}

Array_unique ($cards);

Print_r ($cards);

?

The above mentioned is the whole content of this article, I hope you can like.

http://www.bkjia.com/PHPjc/1000077.html www.bkjia.com true http://www.bkjia.com/PHPjc/1000077.html techarticle PHP Write bulk generate non-duplicated card number password code This article to share is a very practical code, the project often need to use, can batch generate non-duplicated card number password ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.