How to separate sets of numbers onto separate lines

Posted by Fred on Stack Overflow See other posts from Stack Overflow or by Fred
Published on 2012-06-06T04:54:09Z Indexed on 2012/06/07 4:40 UTC
Read the original article Hit count: 214

Filed under:
|

About the script:

The script below will create 300 sets of random characters.

What is presently happening, is that it creates them but shows them all on one line, in one big chunk.

With all the searching and testing I've done to try and achieve this, I have had no success.

I would like to know which code and where to put it, so that each SET (300) of 15 characters long, will show and be saved to file.

Here is my script:

<?php

function GetID($x){

$characters = array_merge(range('A','Z'),range('a','z'),range(2,9));
shuffle($characters);


for($x=0;$x<=299;$x++){

}

for (; strlen($ReqID)<$x;){
$ReqID .= $characters[mt_rand(0, count($characters))];
}


return $ReqID;
}     

$ReqID .= GetID(5);
$ReqID .= "-";
$ReqID .= GetID(5);
$ReqID .= "-";
$ReqID .= GetID(5);


echo $ReqID;


$fh = fopen("file.txt","a+");
fwrite($fh, ("$ReqID")."\n");
fclose($fh);

?>

© Stack Overflow or respective owner

Related posts about php

Related posts about newline