1. Go to this page and download the library: Download gears/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/ */
// Import the functions
use function Gears\Arrays\add;
use function Gears\Arrays\set;
use function Gears\Arrays\forget;
// This results in the same array
$data = [];
$data = add($data, 'a.b.c', 'd');
set($data, 'a.b.c', 'foo');
forget($data, 'a.b.c');
// Import the Array class
use Gears\Arrays as Arr;
// This results in the same array
$data = [];
$data = Arr::add($data, 'a.b.c', 'd');
Arr::set($data, 'a.b.c', 'foo');
Arr::forget($data, 'a.b.c');
$data = new Gears\Arrays\Fluent();
$data[] = 'foo';
$data[] = 'bar';
foreach ($data as $item)
{
echo $item.',';
}
// you would see: foo,bar
$real_array = $data->toArray();
// Import the Array class
use Gears\Arrays as Arr;
// Use the factory method
$data = Arr::a();