PHP code example of vbpupil / attributes

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

    

vbpupil / attributes example snippets




use vbpupil\Attributes;
use vbpupil\Attribute;


//create individual attribute
$attr = new Attribute(['foo'=>'bar']);
$attr->getKey();
$attr->getValue();


//create a new bunch of attributes
try {
    $attrs = new Attributes(
        [
            new Attribute(['product_code'=>'126FGE']),
            new Attribute(['sell_price'=>3.80]),
            new Attribute(['buy_price'=>1.90])
        ],
        [
            'product_code'
        ]
    );
} catch (\Exception $e) {

}

$attrs->getAttribute('product_code');
$attrs->getAttribute('product_code')->getValue();