Advertisement
punkwasp

Randomize pronouns in PHP

Sep 30th, 2023 (edited)
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | Source Code | 0 0
  1. <?php
  2. // Edit this to use the pronouns you actually want. You must include all five forms of the pronoun, even if some of those forms are the same.
  3. $pronouns = array (
  4.     array("it","it","its","its","itself"),
  5.     array("xe","xem","xir","xirs","xemself"),
  6.     array("they","them","their","theirs","themselves"),
  7.     array("he","him","his","his","himself"),
  8.     array("she","her","her","hers","herself"),
  9.     array("ne","nym","nis","nis","nymself")
  10. );
  11.  
  12. // This shuffles the array each time someone loads the page.
  13. shuffle($pronouns);
  14. ?>
  15.  
  16. <!-- Here's where you use the pronouns, if it needs to be capitalized you need to wrap it in the ucfirst() function. I put an if/else statement to check if the pronouns being used are they/them and change the verb form appropriately, since it's relevant for this sentence. The second usage of PHP code is selecting the possessive pronoun. The second number is the element in the child array that you want to select, remember it starts at 0, so it should be a number between 0 and 4. -->
  17. <p>
  18. <?php
  19. echo ucfirst($wasppronouns[0][0]);
  20. if ($wasppronouns[0][0] == "they") {
  21.     echo " like";
  22. }
  23. else {
  24.     echo " likes";
  25. }
  26. ?> macaroni and cheese, it's <?php echo $wasppronouns[0][2]; ?> favorite food.</p>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement