PHP code example of javiereguiluz / easyslugger

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

    

javiereguiluz / easyslugger example snippets


use EasySlugger\Slugger;

$slug = Slugger::slugify('Lorem Ipsum');  // slug = lorem-ipsum

// PHP 5.4 or lower
use EasySlugger\Slugger;

$slugger = new Slugger();
$slug = $slugger->slugify('Lorem Ipsum'); // slug = lorem-ipsum

// PHP 5.5 or higher
$slugger = (new \EasySlugger\Slugger())->slugify('Lorem Ipsum');

use EasySlugger\Slugger;

$slug = Slugger::uniqueSlugify('Lorem Ipsum'); // slug = lorem-ipsum-a2b342f

use EasySlugger\Utf8Slugger;

$slug = Utf8Slugger::slugify('日本語');  // slug = ri-ben-yu
$slug = Utf8Slugger::slugify('العَرَبِيةُ‎‎');    // slug = alrbyt
$slug = Utf8Slugger::slugify('עברית');  // slug = bryt

use EasySlugger\SeoSlugger;

$slug = SeoSlugger::slugify('The price is $5.99');
// slug = the-price-is-5-dollars-99-cents

$slug = SeoSlugger::slugify('Use [email protected] to get a 10% discount');
// slug = use-lorem-at-ipsum-dot-com-to-get-a-10-percent-discount

$slug = SeoSlugger::slugify('Gravity = 9.81 m/s2');
// slug = gravity-equals-9-dot-81-m-s2

use EasySlugger\Slugger;

$slugger = new Slugger();
$slug = $slugger::slugify('Lorem Ipsum'); // slug = lorem-ipsum

$slugger = new Slugger('_');
$slug = $slugger::slugify('Lorem Ipsum'); // slug = lorem_ipsum

$slugger = new Slugger('');
$slug = $slugger::slugify('Lorem Ipsum'); // slug = loremipsum

use EasySlugger\Slugger;

$slugger = new Slugger();
$slug = Slugger::slugify('Lorem Ipsum', '_'); // slug = lorem_ipsum
$slug = Slugger::slugify('Lorem Ipsum', '');  // slug = loremipsum

$slugger = new Slugger('+');
$slug = $slugger::slugify('Lorem Ipsum', '_'); // slug = lorem_ipsum