PHP code example of malenki / slug

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

    

malenki / slug example snippets


use \Malenki\Slug;

$s = new Slug('Some string!');

echo $s->render();
//or
echo $s; // toString available, give "some-string"

use \Malenki\Slug;

$s = new Slug('One example string, again!');

$s->rule('!', '-wouah');

echo $s; // "one-example-string-again-wouah"

use \Malenki\Slug;

$s = new Slug();

$s->rule('!', '-wouah')->rule('?', '-huh');
$s->v('Genius!');
echo $s; // "genius-wouah"
$s->v('Genius?');
echo $s; // "genius-huh"

use \Malenki\Slug;

$s = new Slug('one-string');
echo $s; // "one-string"
$s = new Slug('one-string');
echo $s; // "one-string-2"
$s = new Slug('one-string');
echo $s; // "one-string-3"

use \Malenki\Slug;

$s = new Slug('one-string');
echo $s->noHistory(); // "one-string"
$s = new Slug('one-string');
echo $s->noHistory(); // "one-string"
$s = new Slug('one-string');
echo $s->noHistory(); // "one-string"

// or

$s = new Slug();
echo $s->noHistory()->v('one-string'); // "one-string"
echo $s->noHistory()->v('one-string'); // "one-string"
echo $s->noHistory()->v('one-string'); // "one-string"

$s = new Slug();
Slug::history(array('one-string', 'another-one'));
echo $s->v('one-string'); // "one-string-2"

// some french
$s = new Slug('C’est rigolo d’écrire en français !');
echo $s; // "c-est-rigolo-d-ecrire-en-francais"

// some greek
$s = new Slug('Τα ελληνικά σου είναι καλύτερα απο τα Γαλλικά μου!');
echo $s; // "ta-ellenika-sou-einai-kalytera-apo-ta-gallika-mou"