PHP code example of pangora / classnames

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

    

pangora / classnames example snippets


Classnames::from(
    'btn',
    ['btn-primary'],
    ['btn-secondary' => false],
    ['btn-wide' => true],
    new StringableObject('btn-lg')
);
// => 'btn btn-primary btn-wide btn-lg'

Classnames::from('btn btn-primary');
// => 'btn btn-primary'

Classnames::from('btn', 'btn-primary');
// => 'btn btn-primary'

Classnames::from('   lots of ', ' space  ');
// => 'lots of space'

Classnames::from('btn', ['btn-primary']);
// => 'btn btn-primary'

Classnames::from([
    'btn' => false,
    'btn-secondary' => false,
    'btn-primary' => true,
]);
// => 'btn btn-primary'

Classnames::from(
    'card',
    new StringableObject('card-lg')
);
// => 'card card-lg'

Classnames::dedupeFrom('a btn b btn c');
// => 'a btn b c'