PHP code example of perryflynn / perrys-tags

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

    

perryflynn / perrys-tags example snippets




// From cliexample.php

sTags\TagCollection;

// Example taglist, could come from sql statement
$taglist = array(
    'language:english',
    'language:german',
    'country:germany',
    'country:united states of america',
    'country:hungary',
    'country:italy',
    'country:spain',
    'country:netherlands',
    'color:green',
    'color:red',
    'color:yellow',
    'color:gray',
    'color:blue',
    'color:white',
    'color:light orange',
    'condition:slightly used',
    'condition:used',
    'condition:new',
    'condition:broken',
);

// Create tag collection
$collection = new TagCollection();

// Import tags
foreach($taglist as $tag)
{
    $collection->add($tag);
}

// Prints result of a search
// Supports Regex
var_dump($collection->tagSearch('country~:"^united states" color~:"e$" condition:used')->getTags()->serialize());