PHP code example of ohchiko / randomizer

1. Go to this page and download the library: Download ohchiko/randomizer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ohchiko / randomizer example snippets


$random = Randomizer::generate();

string(21) "kerikilLajuLiontin*!%"    // Using default language (id)

Randomizer::generate(1, 3);    // returns something like: string(11) "sekarang(@!"
Randomizer::generate(3, 1);    // returns something like: string(11) "batuPesawatSekolah&"

Randomizer::setLanguage(Randomizer::LANG_EN);    // or Randomizer::setLanguge('en');
Randomizer::generate();

Randomizer::setCustomWordset(["english", "okay", "airplane", "sky", "eyeglasses", "noise"]);
Randomizer::setCustomPunctset([";", ">", "=", "?"]);

Randomizer::generate(int $wordCount = 3, int $punctCount = 3): string   // Generate a string containing random words and punctuations.
Randomizer::setLanguage(string $language): void                         // Sets the wordset language to randomized. Only supported languages.
Randomizer::getLanguage(): array                                        // Gets the current wordset language.
Randomizer::getAvailableLanguages(): array                              // Gets the current supported languages.
Randomizer::setCustomWordset(array $wordset): void                      // Sets a custom wordset to be randomized.
Randomizer::getCustomWordset(): ?array                                  // Gets a list of words of the current customized wordset.
Randomizer::getDefaultWordset(): array                                  // Gets a list of words of the default wordset. Warning: this method may returns a huge number of array members.
Randomizer::setCustomPunctset(array $punctset): void                    // Sets a custom punctset to be randomized.
Randomizer::getCustomPunctset(): ?array                                 // Gets a list of current customized punctset. Returns null if none.
Randomizer::getDefaultPunctset(): array                                 // Gets a list of punctuations of the default punctset.

Randomizer::LANG_ID
Randomizer::LANG_EN