PHP code example of madeitbelgium / spintax

1. Go to this page and download the library: Download madeitbelgium/spintax 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/ */

    

madeitbelgium / spintax example snippets


"madeitbelgium/spintax": "~1.0"

use MadeITBelgium\Spintax\SpintaxFacade as Spintax;

Spintax::parse('Your {text|content} here.')->generate();

use MadeITBelgium\Spintax\SpintaxFacade as Spintax;

$spintax = Spintax::parse('Schrödinger’s Cat is {dead|alive}.');
$string = $spintax->generate();

use MadeITBelgium\Spintax\SpintaxFacade as Spintax;

Spintax::parse('Your {text|content} here.')->getAll();

use MadeITBelgium\Spintax\SpintaxFacade as Spintax;

$spintax = Spintax::parse('Schrödinger’s Cat is {dead|alive}.');
$strings = $spintax->getAll();

use MadeITBelgium\Spintax\SpintaxFacade as Spintax;

$spintax = Spintax::parse('I {love {PHP|Java|C|C++|JavaScript|Python}|hate Ruby}.');
$string = $spintax->generate();

use MadeITBelgium\Spintax\SpintaxFacade as Spintax;

$path = [];

$spintax = Spintax::parse('I {love {PHP|Java|C|C++|JavaScript|Python}|hate Ruby}.');
// since $path is empty, random values will be used for missing indices and $path will be filled with them
$string = $spintax->generate($path);

// from now you can use $path to re-create the same combination
// all these calls will keep returning same string value
$spintax->generate($path);
$spintax->generate($path);
$spintax->generate($path);
$spintax->generate($path);

// this will force generating "I love Java."
$path = [0, 1];
$spintax->generate($path);

use MadeITBelgium\Spintax\SpintaxFacade as Spintax;

$path = [0];

$spintax = Spintax::parse('I {love {PHP|Java|C|C++|JavaScript|Python}|hate Ruby}.');
// this will generate one of "I love {}." variants
$string = $spintax->generate($path);

use MadeITBelgium\Spintax\SpintaxFacade as Spintax;

echo Spintax::replicate('I {love {PHP|Java|C|C++|JavaScript|Python}|hate Ruby}.', '0,0');