---
title: "随机字符串"
author: "conkeyn"
date: "2008-11-07T17:29:16Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2008-11-07T17:29:16Z"
id: 264129
url: "https://conkeyn.iteye.com/blog/264129"
---

```
/**
	 * 随机生成一个确认号(这个确认号要在数据库中查询是否存在)
	 *
	 */
	function genconfirmid($length) {
		$pattern = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		$key="";
		for($i = 0; $i < $length; $i ++) {
			$key .= $pattern{rand ( 0, 35 )};
		}
		return $key;
	}
```