PHP code example of dasprid / cbor
1. Go to this page and download the library: Download dasprid/cbor 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/ */
dasprid / cbor example snippets
$output = new \SplTempFileObject();
(new \DASPRiD\Cbor\CborEncoder($output))->encode((new \DASPRiD\Cbor\CborBuilder())
->add('text')
->add(1234)
->addByteString("\x10")
->addArray()
->add(1)
->add('text')
->end()
->build()
);
$length = $output->ftell();
$output->rewind();
$encodedBytes = $output->fread($length);
$dataItems = \DASPRiD\Cbor\CborDecoder::decodeString($encodedBytes);
foreach ($dataItems as $dataItem) {
// Process data item
}