PHP code example of psx / record

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

    

psx / record example snippets




use PSX\Record\Record;

$record = new Record();
$record->put('foo', 'bar');
$record->putAll(['bar' => 'foo']);

$record->containsKey('foo'); // checks whether the key exists
$record->containsValue('bar'); // checks whether the value exists (strict type check)

$record->get('foo');
$record->getOrDefault('foo', false);
$record->foo; // property access
$record['foo']; // array access

$record->remove('bar');

$record->keySet(); // returns all keys as indexed array
$record->size(); // returns the size of the map
$record->values(); // returns all values as indexed array

\json_encode($record); // results in {"foo": "bar"}

$record = Record::from(['foo' => 'bar']); // create a record from an array