php生成密保卡
程序员文章站
2024-02-01 16:43:04
...
[PHP]代码
<?php /** * Author: wonli * Contact: wonli@live.com * Date: 2011-09 * Description: getvcode() */ $st = microtime(true); function getvcode() { $s = array(); $str = '3456789abcdefghjkmnpqrstuvwxy'; for($k = 65; $k<74; $k++) { for($i = 1; $i<=9; $i++) { $_x=substr(str_shuffle($str), $i, $i+2); $s[chr($k)][$i] = $_x[0].$_x[1]; } } return $s; } $s = getvcode(); $b = serialize($s); echo '<style type="text/css">table{width:350px;height:350px;border:1px solid blue;margin:20px;border-collapse: collapse; }td{text-align:center;border:1px solid #dddddd;} .b{background:#ffffee;} .c{background:#eeffff;}</style>'; echo '<table><tr><td> </td>'; for($i=1;$i<=9;$i++) { echo '<td class="b">'.$i.'</td>'; } echo '</tr>'; foreach($s as $k=>$v) { echo '<tr><td class="c">'.$k.'</td>'; for($i=1;$i<=9;$i++) { echo '<td>'.$v[$i].'</td>'; } echo '</tr>'; } echo '</table>'; echo '<p style="margin-top:20px"></p>'; $et = microtime(true); echo round(($et - $st) * 1000, 2).' 毫秒',' <a href="?view">查看</a> ',' <a href="?close">关闭</a>'; if(isset($_GET['view'])) { echo '<p style="margin-top:100px;"><textarea name="" id="" cols="130" rows="10">'.$b.'</textarea></p>'; } elseif(isset($_GET['close'])) { }
[图片] scode.bmp
[PHP]代码
function getvcode() { $s = array(); $str = '3456789abcdefghjkmnpqrstuvwxy'; for($k = 65; $k<74; $k++) { for($i = 1; $i<=9; $i++) { $_x=substr(str_shuffle($str), $i, $i+2); $s[chr($k)][$i] = $_x[0].$_x[1]; } } return $s; }