如何生成随机字符串+文本+多行 [英] how to generate a random string + text + multiple lines
本文介绍了如何生成随机字符串+文本+多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我实际上从这里得到了这个脚本...但它不是我需要的...
I actually got this script from here... but it is not quite what I needed...
<?php
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
// Echo the random string.
// Optionally, you can give it a desired string length.
<?php echo generateRandomString(); ?>
?>
基本上,我想要这个小的 php 脚本生成数千行(~3000)...
basically, I wanted this small php script to generate thousands of lines (~3000)...
采用这种格式:
mytext/(the_random_string_here)
mytext/(the_random_string_here)
mytext/(the_random_string_here)
mytext/(the_random_string_here)
mytext/(the_random_string_here)
直到最后(约 3000 行),每一行都有一个随机字符串......
up to the very end (~3000 lines) with each line have a random string...
推荐答案
您可以使用 for 循环生成 3000 次
you can use a for loop to generate it 3000 times
for($i = 0; $i < 3000; $i++){
echo 'mytext/'.generateRandomString().'<br>';
}
答案就在您提供的代码片段中
The answer was inside your code snippet that you provided
这篇关于如何生成随机字符串+文本+多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文