Created
February 2, 2012 16:19
-
-
Save akkunchoi/1724338 to your computer and use it in GitHub Desktop.
Make dummy data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$map = array(); | |
for ($i = 0; $i < 10; $i++){ | |
$map[] = chr(ord('0') + $i); | |
} | |
for ($i = 0; $i < 26; $i++){ | |
$map[] = chr(ord('A') + $i); | |
} | |
for ($i = 0; $i < 26; $i++){ | |
$map[] = chr(ord('a') + $i); | |
} | |
$out = ''; | |
$id = 1; | |
for ($i = 1; $i <= 1000000; $i++){ | |
for ($j = 1; $j <= 40; $j++){ | |
// $key = randStr(mt_rand(9, 20)); | |
$key = $j; | |
$value = randStr(mt_rand(10, 50)); | |
$id++; | |
$out .= "$id,$i,$key,$value\n"; | |
} | |
file_put_contents('dummy.txt', $out, FILE_APPEND); | |
$out = ''; | |
echo "$i\n"; | |
} | |
function randStr($len){ | |
global $map; | |
$ret = ''; | |
for ($i = 0; $i < $len; $i++){ | |
$ret .= $map[mt_rand(0, 61)]; | |
} | |
return $ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment