Looping text generator code
Posted: Wed Aug 27, 2003 10:46 am
Hi, very new to the php game and I'm currently playing around with this code (written by Snowknight) that generates random text:
<?php
//Copyright Snowknight
function NewPassword () {
$Text = "This is merely the text that will be encrypted, change it if needed";
$Length = 10; #How long the password will be
$Text = md5($Text);
srand ((double) microtime() * 1000000);
$StringLength = strlen($Text);
$Beginpoint = rand(0,($StringLength-$Length-1));
$EncPassword = substr($Text, $Beginpoint, $Length);
print ("$EncPassword");
}
?>
<html>
<head><title>Password Generator</title>
</head>
<body bgcolor="#FFFFFF">
<?php
NewPassword();
?>
</body>
</html>
I want to generate more than one unique NewPassword and the most that I've done is simply echo the NewPassword script -
<?php
NewPassword();
echo NewPassword();
?>
I'd like to repeat this script 10-100 times, or whatever I choose (I'd also like to add a <br /> properly, as all of my attempts are failing). Is echo the right choice, should I be looping it using 'while' or 'for'? The goal is to learn how to loop and stop after a set number of times. Thanks.
<?php
//Copyright Snowknight
function NewPassword () {
$Text = "This is merely the text that will be encrypted, change it if needed";
$Length = 10; #How long the password will be
$Text = md5($Text);
srand ((double) microtime() * 1000000);
$StringLength = strlen($Text);
$Beginpoint = rand(0,($StringLength-$Length-1));
$EncPassword = substr($Text, $Beginpoint, $Length);
print ("$EncPassword");
}
?>
<html>
<head><title>Password Generator</title>
</head>
<body bgcolor="#FFFFFF">
<?php
NewPassword();
?>
</body>
</html>
I want to generate more than one unique NewPassword and the most that I've done is simply echo the NewPassword script -
<?php
NewPassword();
echo NewPassword();
?>
I'd like to repeat this script 10-100 times, or whatever I choose (I'd also like to add a <br /> properly, as all of my attempts are failing). Is echo the right choice, should I be looping it using 'while' or 'for'? The goal is to learn how to loop and stop after a set number of times. Thanks.