1. Go to this page and download the library: Download madesimple/php-arrays 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/ */
madesimple / php-arrays example snippets
// Create an empty dot array
$dots = new \MadeSimple\Dots();
// Create a dot array with a pre-existing array
$dots = new \MadeSimple\Dots($array);
// Create a dot array with
$dots = new \MadeSimple\Dots([
'address' => [
'houseNo' => '123',
'street' => 'Fake St',
'postCode' => 'AB12 3CD',
],
'comments' => [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Donec nec pellentesque est.',
'Quisque volutpat quam et est laoreet, vitae consectetur erat molestie.',
]
]);
// Set an array after dot array
// Changes will _not_ be reflected in the original array
$dots->setArray($array);
// Set an array as a reference
// Changes will be reflected in the original array
$dots->setReference($array);
// Get a value using dot notation:
echo "Post Code: ", $dots['address.postCode'], PHP_EOL;
// Set a value using dot notation:
$dots['address.postCode'] = 'EF45 6GH';
echo "Post Code: ", $dots['address.postCode'], PHP_EOL;
// Remove a value using dot notation:
unset($dots['address.postCode']);
echo "Exists: ", (isset($dots['address.postCode']) ? 'yes' : 'no'), PHP_EOL;
// Add a value using dot notation:
$dots['address.postCode'] = 'IJ78 9KL';
echo "Post Code: ", $dots['address.postCode'], PHP_EOL;
// Access nth element in an sub array
echo "Comment: ", $dots['comments.1'], PHP_EOL;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.