Random character generator

A simple PHP script which generates descriptors for a character one may want to draw/sketch.

This was created as a recreation of a similar PHP script which was lost. I've written about that experience in more detail in a blog post on my blog.

It generates a random character on page load, but one may also reload the script (through AJAX) without needing to reload the page.

<?php
    $adj = file('adj.txt');
    $noun = file('noun.txt');
    $myth = file('myth.txt');

    $rnd = array_rand($adj, 2);
    $rnd1 = array_rand($noun, 2);
    $rnd2 = array_rand($myth, 2);

    echo "<div>Your Daily Random Generated Character is: " . "</div>\n";
    echo '<span class="large">' . trim($adj[$rnd[0]]) . " " . trim($adj[$rnd[1]]) . " " . "</span>" . '<span class="larger">' . $noun[$rnd1[0]] . " </span>\n";
    echo "<div>who may or may not be " . "</div>\n";
    echo '<div class="large">' . $myth[$rnd2[0]] . "</div>";
?>

Now while this is a super simple script, I wanted to at least take a moment to mention not being a stranger to PHP on my technical portfolio:


2022-08-10