PHP code example of tr33m4n / utilities
1. Go to this page and download the library: Download tr33m4n/utilities 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/ */
tr33m4n / utilities example snippets
$dataCollection = new DataCollection([
'test1' => 'test1',
'test2' => 'test2'
]);
/**
* Or
*
* $dataCollection = DataCollection::from([
* 'test1' => 'test1',
* 'test2' => 'test2'
* ]);
*/
foreach ($dataCollection as $key => $value) {
echo "$key : $value\n";
}
// Filename: test1.php
return [
'test1' => 'test1',
'test2' => 123,
'test3' => [
'test1' => 'test1',
'test2' => 123,
'test3' => [
'test1' => 'test1',
'test2' => [
'test1' => 'deep_value'
],
'test3' => [
'test1' => 'test1'
]
]
]
];
[
'test1' => new ConfigCollection([
'test1' => 'test1',
'test2' => 123,
'test3' => new ConfigCollection([
'test1' => 'test1',
'test2' => 123,
'test3' => new ConfigCollection([
'test1' => 'test1',
'test2' => new ConfigCollection([
'test1' => 'deep_value'
]),
'test3' => new ConfigCollection([
'test1' => 'test1'
])
])
])
])
];
$deepValue = $this->configProvider->get('test1')
->get('test3')
->get('test3')
->get('test2')
->get('test1');
// $deepValue = 'deep_value'
$deepValue = config('test1')->get('test3')
->get('test3')
->get('test2')
->get('test1');
// $deepValue = 'deep_value'