How to create and write to text file a list of two-letter and numbers 0-9 and hyphen in the middle combinations in PHP

1 Answer

0 votes
two_letters_combination();    
    
function two_letters_combination()
{
    $s = "abcdefghijklmnopqrstuvwxyz0123456789";
 
    $f = fopen("d:/two_letters_combination.txt", "a") or die("Error open file!");
    
    $s_size = strlen($s);
    for ($i = 0; $i < $s_size; $i++)
    {
        for ($j = 0; $j < $s_size; $j++)
        {
            fwrite($f, $s[$i] . "-" . $s[$j] . " ");
        }
        fwrite($f, "\r\n");
    }
    fclose($f);
    
    echo "end. check the file.";
}    

/*
run:

end. check the file.

*/

 



answered Oct 4, 2016 by avibootz
...