PHP code example of mvanvu / php-registry

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

    

mvanvu / php-registry example snippets

 php
// Syntax
// Get and filter
$registry->get($var, $defaultValue, $filterType);

// Set and filter
$registry->set($var, $value, $filterType);

// Example

// Return '[email protected]'
$registry = new Registry(['email' => 'john(.doe)@exa//mple.com']);
$email = $registry->get('email', null, 'email');

// Set and filter
$registry->set('email', 'john(.doe)@exa//mple.com', 'email');

// Return '[email protected]'
echo $registry->get('email');
 php
use MaiVu\Php\Registry;

$registry = new Registry($data);

$data is an array
$data = ['foo' => 'bar'];

or is an object
$data = new stdClass;

or is an instance of Registry
$data = new Registry;

or is a json string
$data = '{"foo": "bar"}';

or is php file that must return an array
$data = 'path/to/file/data.php';

or is json file
$data = 'path/to/file/data.json';

 php
use MaiVu\Php\Registry;
$registry = new Registry(['foo' => 'bar']);

// To array
var_dump($registry->toArray());

// To json string
var_dump($registry->toString());