PHP code example of bartoszbartniczak / array-object
1. Go to this page and download the library: Download bartoszbartniczak/array-object 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/ */
bartoszbartniczak / array-object example snippets
$arrayOfObjects = new ArrayOfObjects(\DateTime::class, [new \DateTime(), new \DateTime()]);
$arrayOfObjects[] = new \DateTime();
$arrayOfObjects->offsetSet(4, new \DateTime());
$arrayOfObjects->append(new \DateTime());
use BartoszBartniczak\ArrayObject\ArrayObject;
use BartoszBartniczak\ArrayObject\KeyNamingStrategy\StandardStrategy;
$arrayObject = new ArrayObject([], ArrayObject::DEFAULT_FLAGS, ArrayObject::DEFAULT_ITERATOR_CLASS, new StandardStrategy());
$arrayObject[] = 'a';
$arrayObject[] = 'b';
$arrayObject[] = 'c';
use BartoszBartniczak\ArrayObject\ArrayObject;
use BartoszBartniczak\ArrayObject\KeyNamingStrategy\ValueAsKeyStrategy;
$arrayObject = new ArrayObject([], ArrayObject::DEFAULT_FLAGS, ArrayObject::DEFAULT_ITERATOR_CLASS, new ValueAsKeyStrategy());
$arrayObject[] = 'a';
$arrayObject[] = 'b';
$arrayObject[] = 'c';
use BartoszBartniczak\ArrayObject\ArrayOfObjects;
use BartoszBartniczak\ArrayObject\KeyNamingStrategy\ClosureStrategy;
$closureStrategy = new ClosureStrategy(
function ($key, \DateTime $dateTime){
return $dateTime->format('Y-m-d');
}
);
$arrayOfObjects = new ArrayOfObjects(\DateTime::class, [], ArrayOfObjects::DEFAULT_FLAGS, ArrayOfObjects::DEFAULT_ITERATOR_CLASS, $closureStrategy);
$arrayOfObjects = new \DateTime('2017-03-15');
$arrayOfObjects = new \DateTime('2017-03-16');
$arrayOfObjects = new \DateTime('2017-03-17');