PHP code example of justinskolnick / key-value
1. Go to this page and download the library: Download justinskolnick/key-value 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/ */
justinskolnick / key-value example snippets
$collection = new KeyValue();
$collection->set( 'id', 'bffc4d08-1750-41a7-9fdd-345187eb9ff2' );
echo $collection->get( 'id' ); // 'bffc4d08-1750-41a7-9fdd-345187eb9ff2'
$id = $collection->get( 'id' );
$timestamp = $collection->get( 'created/timestamp' );
$collection = new KeyValue();
$collection = new KeyValue(
[
'id' => 'bffc4d08-1750-41a7-9fdd-345187eb9ff2',
'phone_number' => 8675309,
'was_saved' => false,
]
);
$collection->set( 'id', 'bffc4d08-1750-41a7-9fdd-345187eb9ff2' );
$collection->setMany(
[
'id' => 'bffc4d08-1750-41a7-9fdd-345187eb9ff2',
'phone_number' => 8675309,
'was_saved' => false,
'created' => [
'readable' => 'November 7, 2025',
'timestamp' => '2025-11-07 01:23:45',
],
]
);
if ( $collection->hasAny() ) {
return true;
}
if ( $collection->has( 'id' ) ) {
return true;
}
if ( $collection->hasValueAt( 'id' ) ) {
return true;
}
$id = $collection->get( 'id' );
$all = $collection->getAll();
$keys = $collection->getKeys();
$values = $collection->getValues();
if ( $collection->delete( 'id' ) ) {
echo $collection->get( 'id' ); // null
}
$collection = new KeyValue(
[
'ducks' => 3,
'dogs' => 4,
'horses' => 2,
]
);
$collection->set( 'dogs', 6 );
if ( $collection->reset() ) {
echo $collection->get( 'dogs' ); // 4
}
$collection = new KeyValue(
[
'ducks' => 3,
'dogs' => 4,
'horses' => 2,
]
);
if ( $collection->reset( true ) ) {
echo $collection->get( 'dogs' ); // null
}
if ( $collection->isEmpty() ) {
return true;
}
$collection = new KeyValue( [] );
if ( $collection->isEmpty( true ) ) {
return true;
}
if ( $collection->isNull() ) {
return true;
}