public function testLoadArray()
 {
     $this->assertAttributeNotEmpty('array_ob', $this->ap);
     $this->ap->loadArray(array());
     $this->assertAttributeEmpty('array_ob', $this->ap);
     $this->ap->loadArray(array('some', 'value', 'third'));
     $this->assertEquals(3, count($this->ap->toArray()));
 }
Beispiel #2
0
/**
 * This file is part of the ArrayProperty package.
 *
 * @author Muhammed Mamedov <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
//composer autoload
require __DIR__ . '/../vendor/autoload.php';
use ArrayProperty\ArrayProperty;
//create empty object
$array_property = new ArrayProperty(array());
//empty object verification
var_dump($array_property->toArray());
//not exists
if (!$array_property->exist('firstOne')) {
    echo 'firstOne value not exists<br>';
}
$array_property->firstOne = 'firstvalue';
$array_property->anotherValue = 'anotherOne';
//see new array
var_dump($array_property->toArray());
//access new array elements
echo $array_property->firstOne . '<br>';
echo $array_property->anotherValue . '<br>';
//add more values
$new_add = array('person' => array('name' => 'Muhammed', 'lastname' => 'Mamedov'), 'stuff' => array('read' => 'books', 'hobby' => 'fish'));
//add above array
$array_property->third = $new_add;