Skip to content

Instantly share code, notes, and snippets.

@rskull
Created November 29, 2011 05:26
Show Gist options
  • Save rskull/1403561 to your computer and use it in GitHub Desktop.
Save rskull/1403561 to your computer and use it in GitHub Desktop.
ランダムな文字列の生成
<?php
function randstr ($len) {
$list = 'abcdifghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';
$ls = str_split($list);
for ($i=0;$i<$len;$i++) {
$token .= $ls[mt_rand(0, 62)];
}
return $token;
}
//出力、32文字の文字列
echo randstr(32);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment